This repository has been archived on 2024-08-02. You can view files and clone it, but cannot push or open issues or pull requests.
orion/emlid/reachview/configuration_test.go

92 lines
1.8 KiB
Go
Raw Permalink Normal View History

package reachview
2018-09-20 17:28:18 +02:00
import (
"context"
2018-09-20 17:28:18 +02:00
"testing"
"time"
"forge.cadoles.com/Pyxis/orion/emlid"
2018-09-20 17:28:18 +02:00
)
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),
2018-09-20 17:28:18 +02:00
)
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(), 10*time.Second)
defer applyConfCancel()
result, config, err := client.ApplyConfiguration(ctx, config)
2018-09-20 17:28:18 +02:00
if err != nil {
t.Fatal(err)
2018-09-20 17:28:18 +02:00
}
if config == nil {
t.Fatal("config should not be nil")
}
if config.RTKSettings == nil {
t.Fatal("config.RTKSettings should not be nil")
2018-09-20 17:28:18 +02:00
}
if g, e := result, ConfigurationApplySuccess; g != e {
t.Errorf("result: got '%s', expected '%s'", g, e)
}
2018-09-21 15:39:21 +02:00
2018-09-20 17:28:18 +02:00
defer client.Close()
}