From 4202dcb5aab3c5207defc927d35eea2243d54644 Mon Sep 17 00:00:00 2001 From: Manuel Kieweg <manuel.kieweg@h-da.de> Date: Mon, 29 Mar 2021 17:10:06 +0100 Subject: [PATCH] fix race conditions --- nucleus/integration_test.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/nucleus/integration_test.go b/nucleus/integration_test.go index 171cfd3b9..455138f97 100644 --- a/nucleus/integration_test.go +++ b/nucleus/integration_test.go @@ -263,6 +263,7 @@ func TestGnmi_SubscribeIntegration(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { + var wantErr = tt.wantErr g, err := NewGnmiTransport(tt.fields.opt) if err != nil { t.Error(err) @@ -271,10 +272,10 @@ func TestGnmi_SubscribeIntegration(t *testing.T) { ctx := context.WithValue(context.Background(), CtxKeyOpts, tt.args.opts) //nolint ctx, cancel := context.WithCancel(ctx) go func() { - err = g.Subscribe(ctx) - if (err != nil) != tt.wantErr { - if !tt.wantErr { - if err.Error() != "rpc error: code = Canceled desc = context canceled" { + subErr := g.Subscribe(ctx) + if (subErr != nil) != wantErr { + if !wantErr && subErr != nil{ + if subErr.Error() != "rpc error: code = Canceled desc = context canceled" { t.Errorf("Subscribe() error = %v, wantErr %v", err, tt.wantErr) } } -- GitLab