MCPcopy Create free account
hub / github.com/CrunchyData/postgres-operator / TestMultiSet

Function TestMultiSet

internal/pgbackrest/options_test.go:15–54  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestMultiSet(t *testing.T) {
16 t.Parallel()
17
18 ms := iniMultiSet{}
19 assert.Equal(t, ms.String(), "")
20 assert.DeepEqual(t, ms.Values("any"), []string(nil))
21
22 ms.Add("x", "y")
23 assert.DeepEqual(t, ms.Values("x"), []string{"y"})
24
25 ms.Add("x", "a")
26 assert.DeepEqual(t, ms.Values("x"), []string{"y", "a"})
27
28 ms.Add("abc", "j'l")
29 assert.DeepEqual(t, ms, iniMultiSet{
30 "x": []string{"y", "a"},
31 "abc": []string{"j'l"},
32 })
33 assert.Equal(t, ms.String(),
34 "abc = j'l\nx = y\nx = a\n")
35
36 ms.Set("x", "n")
37 assert.DeepEqual(t, ms.Values("x"), []string{"n"})
38 assert.Equal(t, ms.String(),
39 "abc = j'l\nx = n\n")
40
41 ms.Set("x", "p", "q")
42 assert.DeepEqual(t, ms.Values("x"), []string{"p", "q"})
43
44 t.Run("PrettyYAML", func(t *testing.T) {
45 b, err := yaml.Marshal(iniMultiSet{
46 "x": []string{"y"},
47 "z": []string{""},
48 }.String())
49
50 assert.NilError(t, err)
51 assert.Assert(t, strings.HasPrefix(string(b), `|`),
52 "expected literal block scalar, got:\n%s", b)
53 })
54}
55
56func TestSectionSet(t *testing.T) {
57 t.Parallel()

Callers

nothing calls this directly

Calls 5

StringMethod · 0.95
ValuesMethod · 0.95
AddMethod · 0.95
SetMethod · 0.95
EqualMethod · 0.45

Tested by

no test coverage detected