This commit is contained in:
2025-05-27 16:22:36 +02:00
parent 38a1d5a2c6
commit ecf5fb46a0
11 changed files with 246 additions and 57 deletions

View File

@ -2,6 +2,7 @@ package testsuite
import (
"context"
"fmt"
"math"
"math/rand"
"os"
@ -240,6 +241,105 @@ var testCases = []operationTestCase{
},
},
{
Name: "SetBaseModeAveragePosition",
Run: func(t *testing.T, ops protocol.Operations) {
ctx := context.Background()
if err := ops.Connect(ctx); err != nil {
t.Errorf("%+v", errors.WithStack(err))
return
}
defer func() {
if err := ops.Close(ctx); err != nil {
t.Errorf("%+v", errors.WithStack(err))
}
}()
latitude := -90 + rand.Float64()*180
longitude := -180 + rand.Float64()*360
height := rand.Float64() * 1000
antennaOffset := toFixed(rand.Float64()*2, 3)
opts := []protocol.SetBaseOptionFunc{
protocol.WithBaseLatitude(latitude),
protocol.WithBaseLongitude(longitude),
protocol.WithBaseHeight(height),
protocol.WithBaseAntennaOffset(antennaOffset),
protocol.WithBaseMode(fmt.Sprintf("%s-and-hold", "fix")),
}
if err := ops.SetBase(ctx, opts...); err != nil {
t.Errorf("%+v", errors.WithStack(err))
}
},
},
{
Name: "AveragePosition",
Run: func(t *testing.T, ops protocol.Operations) {
ctx := context.Background()
if err := ops.Connect(ctx); err != nil {
t.Errorf("%+v", errors.WithStack(err))
return
}
defer func() {
if err := ops.Close(ctx); err != nil {
t.Errorf("%+v", errors.WithStack(err))
}
}()
taskmessage, err := ops.AveragePosition(ctx)
if err != nil {
t.Errorf("%+v", errors.WithStack(err))
return
}
fmt.Println(taskmessage)
},
},
{
Name: "GetNTRIPMountPoint",
Run: func(t *testing.T, ops protocol.Operations) {
ctx := context.Background()
if err := ops.Connect(ctx); err != nil {
t.Errorf("%+v", errors.WithStack(err))
return
}
defer func() {
if err := ops.Close(ctx); err != nil {
t.Errorf("%+v", errors.WithStack(err))
}
}()
if err := ops.GetNTRIPMountPoint(ctx); err != nil {
t.Errorf("%+v", errors.WithStack(err))
return
}
broadcastCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
messages, err := ops.On(broadcastCtx, "task_status")
if err != nil {
t.Errorf("%+v", errors.WithStack(err))
return
}
count := 0
for m := range messages {
t.Logf("new message: %s", spew.Sdump(m))
count++
}
if e, g := 1, count; g < e {
t.Errorf("expected total messages > %d, got %d", e, g)
}
},
},
}
func TestOperations(t *testing.T, opsFactory OperationsFactoryFunc) {

View File

@ -0,0 +1,16 @@
package testsuite
import (
"testing"
"forge.cadoles.com/cadoles/go-emlid/reach/client"
"forge.cadoles.com/cadoles/go-emlid/reach/client/protocol"
)
func TestReachOperations(t *testing.T) {
opsFactory := func(addr string) (protocol.Operations, error) {
return client.NewClient(addr), nil
}
TestOperations(t, opsFactory)
}