MCPcopy Index your code
hub / github.com/coder/coder / TestParseStringSliceClaim

Function TestParseStringSliceClaim

coderd/idpsync/idpsync_test.go:56–180  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

54}
55
56func TestParseStringSliceClaim(t *testing.T) {
57 t.Parallel()
58
59 cases := []struct {
60 Name string
61 GoClaim interface{}
62 // JSON Claim allows testing the json -> go conversion
63 // of some strings.
64 JSONClaim string
65 ErrorExpected bool
66 ExpectedSlice []string
67 }{
68 {
69 Name: "Nil",
70 GoClaim: nil,
71 ExpectedSlice: []string{},
72 },
73 // Go Slices
74 {
75 Name: "EmptySlice",
76 GoClaim: []string{},
77 ExpectedSlice: []string{},
78 },
79 {
80 Name: "StringSlice",
81 GoClaim: []string{"a", "b", "c"},
82 ExpectedSlice: []string{"a", "b", "c"},
83 },
84 {
85 Name: "InterfaceSlice",
86 GoClaim: []interface{}{"a", "b", "c"},
87 ExpectedSlice: []string{"a", "b", "c"},
88 },
89 {
90 Name: "MixedSlice",
91 GoClaim: []interface{}{"a", string("b"), interface{}("c")},
92 ExpectedSlice: []string{"a", "b", "c"},
93 },
94 {
95 Name: "StringSliceOneElement",
96 GoClaim: []string{"a"},
97 ExpectedSlice: []string{"a"},
98 },
99 // Json Slices
100 {
101 Name: "JSONEmptySlice",
102 JSONClaim: `[]`,
103 ExpectedSlice: []string{},
104 },
105 {
106 Name: "JSONStringSlice",
107 JSONClaim: `["a", "b", "c"]`,
108 ExpectedSlice: []string{"a", "b", "c"},
109 },
110 {
111 Name: "JSONStringSliceOneElement",
112 JSONClaim: `["a"]`,
113 ExpectedSlice: []string{"a"},

Callers

nothing calls this directly

Calls 4

ParseStringSliceClaimFunction · 0.92
RunMethod · 0.65
UnmarshalMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected