-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
Copy pathdependency_test.go
33 lines (29 loc) · 1022 Bytes
/
dependency_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package query_test
import (
"context"
"testing"
"github.com/influxdata/influxdb"
"github.com/influxdata/influxdb/mock"
"github.com/influxdata/influxdb/query"
)
func TestSecretLookup(t *testing.T) {
req := &query.Request{OrganizationID: orgID}
ctx := query.ContextWithRequest(context.Background(), req)
svc := &mock.SecretService{
LoadSecretFn: func(ctx context.Context, orgID influxdb.ID, k string) (string, error) {
if want, got := req.OrganizationID, orgID; want != got {
t.Errorf("unexpected organization id -want/+got:\n\t- %v\n\t+ %v", want, got)
}
if want, got := "mysecret", k; want != got {
t.Errorf("unexpected secret key -want/+got:\n\t- %v\n\t+ %v", want, got)
}
return "mypassword", nil
},
}
dep := query.FromSecretService(svc)
if val, err := dep.LoadSecret(ctx, "mysecret"); err != nil {
t.Errorf("unexpected error: %s", err)
} else if want, got := "mypassword", val; want != got {
t.Errorf("unexpected secret value -want/+got:\n\t- %v\n\t+ %v", want, got)
}
}