(testCase getProfilesTestCase, t *testing.T)
| 431 | } |
| 432 | |
| 433 | func 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 | |
| 471 | type parseCommandsTestCase struct { |
| 472 | name string |
no test coverage detected