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

fix race conditions

parent aec9f431
No related branches found
No related tags found
2 merge requests!124Resolve "Job Failed #246137",!90Develop
...@@ -263,6 +263,7 @@ func TestGnmi_SubscribeIntegration(t *testing.T) { ...@@ -263,6 +263,7 @@ func TestGnmi_SubscribeIntegration(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
var wantErr = tt.wantErr
g, err := NewGnmiTransport(tt.fields.opt) g, err := NewGnmiTransport(tt.fields.opt)
if err != nil { if err != nil {
t.Error(err) t.Error(err)
...@@ -271,10 +272,10 @@ func TestGnmi_SubscribeIntegration(t *testing.T) { ...@@ -271,10 +272,10 @@ func TestGnmi_SubscribeIntegration(t *testing.T) {
ctx := context.WithValue(context.Background(), CtxKeyOpts, tt.args.opts) //nolint ctx := context.WithValue(context.Background(), CtxKeyOpts, tt.args.opts) //nolint
ctx, cancel := context.WithCancel(ctx) ctx, cancel := context.WithCancel(ctx)
go func() { go func() {
err = g.Subscribe(ctx) subErr := g.Subscribe(ctx)
if (err != nil) != tt.wantErr { if (subErr != nil) != wantErr {
if !tt.wantErr { if !wantErr && subErr != nil{
if err.Error() != "rpc error: code = Canceled desc = context canceled" { if subErr.Error() != "rpc error: code = Canceled desc = context canceled" {
t.Errorf("Subscribe() error = %v, wantErr %v", err, tt.wantErr) t.Errorf("Subscribe() error = %v, wantErr %v", err, tt.wantErr)
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment