orion/emlid/reachview/configuration_test.go

92 lines
1.8 KiB
Go

package reachview
import (
"context"
"testing"
"time"
"forge.cadoles.com/Pyxis/orion/emlid"
)
func TestReachViewConfiguration(t *testing.T) {
if !*runReachViewIntegrationTests {
t.Skip("To run this test, use: go test -reachview-integration")
}
client := NewClient(
emlid.WithStandardLogger(),
emlid.WithEndpoint(*reachHost, 80),
)
if err := client.Connect(); err != nil {
t.Fatal(err)
}
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
config, err := client.Configuration(ctx)
if err != nil {
t.Error(err)
}
if config == nil {
t.Fatal("config should not be nil")
}
if config.RTKSettings == nil {
t.Fatal("config.RTKSettings should not be nil")
}
defer client.Close()
}
func TestReachViewApplyConfiguration(t *testing.T) {
if !*runReachViewIntegrationTests {
t.Skip("To run this test, use: go test -reachview-integration")
}
client := NewClient(
emlid.WithStandardLogger(),
emlid.WithEndpoint(*reachHost, 80),
)
if err := client.Connect(); err != nil {
t.Fatal(err)
}
ctx, configurationCancel := context.WithTimeout(context.Background(), 5*time.Second)
defer configurationCancel()
config, err := client.Configuration(ctx)
if err != nil {
t.Error(err)
}
config.RTKSettings.PositionningMode = String("single")
ctx, applyConfCancel := context.WithTimeout(context.Background(), 5*time.Second)
defer applyConfCancel()
result, config, err := client.ApplyConfiguration(ctx, config)
if err != nil {
t.Error(err)
}
if config == nil {
t.Fatal("config should not be nil")
}
if config.RTKSettings == nil {
t.Fatal("config.RTKSettings should not be nil")
}
if g, e := result, ConfigurationApplySuccess; g != e {
t.Errorf("result: got '%s', expected '%s'", g, e)
}
defer client.Close()
}