2018-09-21 12:31:52 +02:00
|
|
|
package reachview
|
2018-09-20 17:28:18 +02:00
|
|
|
|
|
|
|
import (
|
2018-09-26 15:56:06 +02:00
|
|
|
"context"
|
2018-09-20 17:28:18 +02:00
|
|
|
"testing"
|
2018-09-26 15:56:06 +02:00
|
|
|
"time"
|
2018-09-21 12:31:52 +02:00
|
|
|
|
|
|
|
"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")
|
|
|
|
}
|
|
|
|
|
2018-09-21 12:31:52 +02:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2018-09-26 15:56:06 +02:00
|
|
|
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")
|
|
|
|
|
2018-09-26 16:59:07 +02:00
|
|
|
ctx, applyConfCancel := context.WithTimeout(context.Background(), 10*time.Second)
|
2018-09-26 15:56:06 +02:00
|
|
|
defer applyConfCancel()
|
|
|
|
|
|
|
|
result, config, err := client.ApplyConfiguration(ctx, config)
|
2018-09-20 17:28:18 +02:00
|
|
|
if err != nil {
|
2018-09-26 16:59:07 +02:00
|
|
|
t.Fatal(err)
|
2018-09-20 17:28:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if config == nil {
|
2018-09-20 17:40:23 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2018-09-26 15:56:06 +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()
|
|
|
|
|
|
|
|
}
|