-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathplugin_test.go
56 lines (50 loc) · 979 Bytes
/
plugin_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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package sdk
import (
"bytes"
"encoding/json"
"reflect"
"testing"
)
func TestGetResultListKeyId(t *testing.T) {
cases := []struct {
Name string
KeyId uint64
Expected *GetResult
}{
{
Name: "found",
KeyId: 42,
Expected: &GetResult{KeyId: 42},
},
{
Name: "not found",
KeyId: 43,
Expected: nil,
},
}
results := GetResultList([]*GetResult{
{
KeyId: 42,
},
})
for _, tc := range cases {
tc := tc
t.Run(tc.Name, func(t *testing.T) {
actual := results.KeyId(tc.KeyId)
if !reflect.DeepEqual(tc.Expected, actual) {
t.Fatalf("expected %#v, got %#v", tc.Expected, actual)
}
})
}
}
func Test_Null_MarshalJSON(t *testing.T) {
res, err := json.Marshal(Null)
if err != nil {
t.Fatal(err)
}
if !bytes.Equal(res, []byte("null")) {
t.Fatalf("unexpected response, marshal of Null should be \"null\", got %q", string(res))
}
}