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

Function testGetProfiles

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

Source from the content-addressed store, hash-verified

431}
432
433func testGetProfiles(testCase getProfilesTestCase, t *testing.T) {
434 defer func() {
435 for _, path := range []string{".devspace/generated.yaml", "devspace.yaml", "custom.yaml"} {
436 os.Remove(path)
437 }
438 }()
439 for path, data := range testCase.files {
440 dataAsYaml, err := yaml.Marshal(data)
441 assert.NilError(t, err, "Error parsing data of file %s in testCase %s", path, testCase.name)
442 err = fsutil.WriteToFile([]byte(dataAsYaml), path)
443 assert.NilError(t, err, "Error writing file %s in testCase %s", path, testCase.name)
444 }
445
446 loader := &configLoader{
447 absConfigPath: testCase.configPath,
448 }
449 c, err := loader.LoadWithParser(context.Background(),
450 localcache.New(constants.DefaultCacheFolder),
451 &fakekubectl.Client{Client: fake.NewSimpleClientset()},
452 NewProfilesParser(),
453 &ConfigOptions{},
454 log.Discard)
455 assert.NilError(t, err, "Error loading config in testCase %s", testCase.name)
456 profileObjects := c.Config().Profiles
457 profiles := []string{}
458 for _, p := range profileObjects {
459 profiles = append(profiles, p.Name)
460 }
461
462 if testCase.expectedErr == "" {
463 assert.NilError(t, err, "Error in testCase %s", testCase.name)
464 } else {
465 assert.Error(t, err, testCase.expectedErr, "Wrong or no error in testCase %s", testCase.name)
466 }
467
468 assert.Equal(t, strings.Join(profiles, ","), strings.Join(testCase.expectedProfiles, ","), "Unexpected profiles in testCase %s", testCase.name)
469}
470
471type parseCommandsTestCase struct {
472 name string

Callers 1

TestGetProfilesFunction · 0.85

Calls 8

LoadWithParserMethod · 0.95
WriteToFileFunction · 0.92
NewFunction · 0.92
NewProfilesParserFunction · 0.85
EqualMethod · 0.80
RemoveMethod · 0.65
ConfigMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected