Skip to content
Snippets Groups Projects
Commit 74fa95fc authored by Manuel Kieweg's avatar Manuel Kieweg
Browse files

gracefully end Subscribe()-Test

parent f6a5e620
No related branches found
No related tags found
2 merge requests!112Integration test,!90Develop
......@@ -203,8 +203,10 @@ func (g *Gnmi) subscribe(ctx context.Context) error {
go func() {
for {
resp := <-g.RespChan
if err := gnmi.LogSubscribeResponse(resp); err != nil {
log.Fatal(err)
if resp != nil {
if err := gnmi.LogSubscribeResponse(resp); err != nil {
log.Fatal(err)
}
}
}
}()
......
......@@ -5,6 +5,7 @@ import (
"code.fbi.h-da.de/cocsn/gosdn/nucleus/util"
"context"
gpb "github.com/openconfig/gnmi/proto/gnmi"
"reflect"
"testing"
"time"
)
......@@ -95,15 +96,14 @@ func TestGnmi_SubscribeIntegration(t *testing.T) {
Target: address,
}
ctx := context.WithValue(context.Background(), "opts", opts)
d := time.Now().Add(60 * time.Second)
ctx, cancel := context.WithDeadline(ctx, d)
defer cancel()
go func() {
if err := transport.Subscribe(ctx); err != nil {
t.Error(err)
}
}()
time.Sleep(time.Second * 50)
time.Sleep(time.Second * 30)
ctx.Done()
time.Sleep(time.Second * 5)
})
}
......@@ -134,8 +134,8 @@ func TestGnmi_CapabilitiesIntegration(t *testing.T) {
if err != nil {
t.Error(err)
}
if resp != v {
t.Error("resp is nil")
if !reflect.DeepEqual(resp, v) {
t.Errorf("Capabilities() = %v, want %v", resp, v)
}
})
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment