MCPcopy
hub / github.com/grafana/dskit / Test_StringSliceCSV

Function Test_StringSliceCSV

flagext/stringslicecsv_test.go:10–34  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func Test_StringSliceCSV(t *testing.T) {
11 type TestStruct struct {
12 CSV StringSliceCSV `yaml:"csv"`
13 }
14
15 var testStruct TestStruct
16 s := "a,b,c,d"
17 assert.Nil(t, testStruct.CSV.Set(s))
18
19 assert.Equal(t, []string{"a", "b", "c", "d"}, []string(testStruct.CSV))
20 assert.Equal(t, s, testStruct.CSV.String())
21
22 expected := []byte(`csv: a,b,c,d
23`)
24
25 actual, err := yaml.Marshal(testStruct)
26 assert.Nil(t, err)
27 assert.Equal(t, expected, actual)
28
29 var testStruct2 TestStruct
30
31 err = yaml.Unmarshal(expected, &testStruct2)
32 assert.Nil(t, err)
33 assert.Equal(t, testStruct, testStruct2)
34}
35
36func Test_EmptyStringSliceCSV(t *testing.T) {
37 type TestStruct struct {

Callers

nothing calls this directly

Calls 5

SetMethod · 0.65
StringMethod · 0.65
EqualMethod · 0.45
MarshalMethod · 0.45
UnmarshalMethod · 0.45

Tested by

no test coverage detected