Skip to content
Snippets Groups Projects
Commit c38cf281 authored by Malte Bauch's avatar Malte Bauch
Browse files

Revert "some minor adjustments for context keys"

This reverts commit 3cbe1d63.
parent 3cbe1d63
No related branches found
No related tags found
2 merge requests!120Resolve "Code Quality",!90Develop
...@@ -11,16 +11,10 @@ import ( ...@@ -11,16 +11,10 @@ import (
"strings" "strings"
) )
// CtxKeyType is a custom type to be used as key in a context.WithValue() or type CtxKeyType string
// context.Value() call. For more information see:
// https://www.calhoun.io/pitfalls-of-context-values-and-how-to-avoid-or-mitigate-them/
type CtxKeyType int
const ( const (
// CtxKeyOpts context key for gnmi.SubscribeOptions CtxKeyOpts CtxKeyType = "opts"
CtxKeyOpts CtxKeyType = iota CtxKeyConfig = "config"
// CtxKeyConfig is a context key for gnmi.Config
CtxKeyConfig
) )
// Gnmi implements the Transport interface and provides an SBI with the // Gnmi implements the Transport interface and provides an SBI with the
......
...@@ -109,7 +109,7 @@ func TestGnmi_SetIntegration(t *testing.T) { ...@@ -109,7 +109,7 @@ func TestGnmi_SetIntegration(t *testing.T) {
if err != nil && tt.wantErr { if err != nil && tt.wantErr {
return return
} else if got.Prefix.Target != address || } else if got.Prefix.Target != address ||
got.Response[0].Op != gpb.UpdateResult_UPDATE { got.Response[0].Op != gpb.UpdateResult_UPDATE{
t.Errorf("Set() got = %v, want %v", got, tt.want) t.Errorf("Set() got = %v, want %v", got, tt.want)
} }
}) })
...@@ -271,7 +271,7 @@ func TestGnmi_SubscribeIntegration(t *testing.T) { ...@@ -271,7 +271,7 @@ func TestGnmi_SubscribeIntegration(t *testing.T) {
t.Error(err) t.Error(err)
return return
} }
ctx := context.WithValue(context.Background(), CtxKeyOpts, tt.args.opts) ctx := context.WithValue(context.Background(), "opts", tt.args.opts)
ctx, cancel := context.WithCancel(ctx) ctx, cancel := context.WithCancel(ctx)
go func() { go func() {
err = g.Subscribe(ctx) err = g.Subscribe(ctx)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment