MCPcopy
hub / github.com/vmware-tanzu/sonobuoy / TestEmptySlicePreservation

Function TestEmptySlicePreservation

pkg/config/config_test.go:37–73  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

35}
36
37func TestEmptySlicePreservation(t *testing.T) {
38 for _, tc := range []struct {
39 desc string
40 cfgfunc func() *config.Config
41 }{
42 {
43 desc: "Default config",
44 cfgfunc: config.New,
45 }, {
46 desc: "Empty resources and plugin selection",
47 cfgfunc: func() *config.Config {
48 cfg := config.New()
49 cfg.Resources = []string{}
50 cfg.PluginSelections = []plugin.Selection{}
51 return cfg
52 },
53 },
54 } {
55 t.Run(tc.desc, func(t *testing.T) {
56 cfg1 := tc.cfgfunc()
57 b, err := json.Marshal(cfg1)
58 if err != nil {
59 t.Fatalf("Unable to marshal config: %v", err)
60 }
61
62 var cfg2 *config.Config
63 err = json.Unmarshal(b, &cfg2)
64 if err != nil {
65 t.Fatalf("Unable to unmarshal config: %v", err)
66 }
67
68 if !reflect.DeepEqual(cfg1, cfg2) {
69 t.Fatalf("Values did not match after serialization/deserialization: \nGot: %#v\n\nWant: %#v\n", cfg2, cfg1)
70 }
71 })
72 }
73}

Callers

nothing calls this directly

Calls 2

NewFunction · 0.92
RunMethod · 0.65

Tested by

no test coverage detected