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.
2018-10-09 14:05:38 +02:00
|
|
|
package emlid
|
|
|
|
|
|
|
|
import (
|
2018-10-16 15:23:16 +02:00
|
|
|
"context"
|
2018-10-09 14:05:38 +02:00
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestDiscovery(t *testing.T) {
|
|
|
|
|
|
|
|
if !*runDiscoveryIntegrationTests {
|
|
|
|
t.Skip("To run this test, use: go test -discovery-integration")
|
|
|
|
}
|
|
|
|
|
2018-10-16 15:23:16 +02:00
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
services, err := Discover(ctx)
|
2018-10-09 14:05:38 +02:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if g, e := len(services), 1; g != e {
|
|
|
|
t.Fatalf("len(services): got '%d', expected '%d'", g, e)
|
|
|
|
}
|
|
|
|
|
|
|
|
s := services[0]
|
|
|
|
|
|
|
|
if g, e := s.Name, "reach"; g != e {
|
|
|
|
t.Errorf("services[0].Name: got '%s', expected '%s'", g, e)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|