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

Function testLoad

pkg/devspace/config/loader/loader_test.go:216–247  ·  view source on GitHub ↗
(testCase *loadTestCase, t *testing.T)

Source from the content-addressed store, hash-verified

214}
215
216func testLoad(testCase *loadTestCase, t *testing.T) {
217 defer func() {
218 for _, path := range []string{".devspace/generated.yaml", "devspace.yaml", "custom.yaml"} {
219 os.Remove(path)
220 }
221 }()
222 for path, data := range testCase.files {
223 dataAsYaml, err := yaml.Marshal(data)
224 assert.NilError(t, err, "Error parsing data of file %s in testCase %s", path, testCase.name)
225 err = fsutil.WriteToFile([]byte(dataAsYaml), path)
226 assert.NilError(t, err, "Error writing file %s in testCase %s", path, testCase.name)
227 }
228
229 loader := &configLoader{
230 absConfigPath: testCase.configPath,
231 }
232
233 var config config2.Config
234 var err error
235 config, err = loader.Load(context.TODO(), nil, &testCase.options, log.Discard)
236 if testCase.expectedErr == "" {
237 assert.NilError(t, err, "Error in testCase %s", testCase.name)
238 } else {
239 assert.Error(t, err, testCase.expectedErr, "Wrong or no error in testCase %s", testCase.name)
240 }
241
242 configAsYaml, err := yaml.Marshal(config.Config())
243 assert.NilError(t, err, "Error parsing config in testCase %s", testCase.name)
244 expectedAsYaml, err := yaml.Marshal(testCase.expectedConfig)
245 assert.NilError(t, err, "Error parsing exception to yaml in testCase %s", testCase.name)
246 assert.Equal(t, string(configAsYaml), string(expectedAsYaml), "Unexpected config in testCase %s", testCase.name)
247}
248
249type setDevSpaceRootTestCase struct {
250 name string

Callers 1

TestLoadFunction · 0.70

Calls 6

LoadMethod · 0.95
ConfigMethod · 0.95
WriteToFileFunction · 0.92
EqualMethod · 0.80
RemoveMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected