MCPcopy Index your code
hub / github.com/devspace-sh/devspace / testLoad

Function testLoad

pkg/devspace/config/localcache/config_test.go:61–89  ·  view source on GitHub ↗
(testCase loadTestCase, t *testing.T)

Source from the content-addressed store, hash-verified

59}
60
61func testLoad(testCase loadTestCase, t *testing.T) {
62 defer func() {
63 for _, path := range []string{".devspace/cache.yaml"} {
64 os.Remove(path)
65 }
66 }()
67 for path, data := range testCase.files {
68 dataAsYaml, err := yaml.Marshal(data)
69 assert.NilError(t, err, "Error parsing data of file %s in testCase %s", path, testCase.name)
70 err = fsutil.WriteToFile([]byte(dataAsYaml), path)
71 assert.NilError(t, err, "Error writing file %s in testCase %s", path, testCase.name)
72 }
73
74 loader := NewCacheLoader()
75
76 config, err := loader.Load(constants.DefaultConfigPath)
77
78 if testCase.expectedErr == "" {
79 assert.NilError(t, err, "Error in testCase %s", testCase.name)
80 } else {
81 assert.Error(t, err, testCase.expectedErr, "Wrong or no error in testCase %s", testCase.name)
82 }
83
84 configAsYaml, err := yaml.Marshal(config)
85 assert.NilError(t, err, "Error parsing config in testCase %s", testCase.name)
86 expectedAsYaml, err := yaml.Marshal(testCase.expectedConfig)
87 assert.NilError(t, err, "Error parsing exception to yaml in testCase %s", testCase.name)
88 assert.Equal(t, string(configAsYaml), string(expectedAsYaml), "Unexpected config in testCase %s", testCase.name)
89}
90
91type saveTestCase struct {
92 name string

Callers 1

TestLoadFunction · 0.70

Calls 6

WriteToFileFunction · 0.92
EqualMethod · 0.80
NewCacheLoaderFunction · 0.70
RemoveMethod · 0.65
LoadMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected