| 20 | } |
| 21 | |
| 22 | func TestLoad(t *testing.T) { |
| 23 | testCases := []loadTestCase{ |
| 24 | { |
| 25 | name: "no config file", |
| 26 | expectedConfig: &LocalCache{}, |
| 27 | }, |
| 28 | { |
| 29 | name: "load empty config file", |
| 30 | files: map[string]interface{}{ |
| 31 | ".devspace/generated.yaml": struct{}{}, |
| 32 | }, |
| 33 | expectedConfig: &LocalCache{}, |
| 34 | }, |
| 35 | } |
| 36 | |
| 37 | dir := t.TempDir() |
| 38 | |
| 39 | wdBackup, err := os.Getwd() |
| 40 | if err != nil { |
| 41 | t.Fatalf("Error getting current working directory: %v", err) |
| 42 | } |
| 43 | err = os.Chdir(dir) |
| 44 | if err != nil { |
| 45 | t.Fatalf("Error changing working directory: %v", err) |
| 46 | } |
| 47 | |
| 48 | defer func() { |
| 49 | //Delete temp folder |
| 50 | err = os.Chdir(wdBackup) |
| 51 | if err != nil { |
| 52 | t.Fatalf("Error changing dir back: %v", err) |
| 53 | } |
| 54 | }() |
| 55 | |
| 56 | for _, testCase := range testCases { |
| 57 | testLoad(testCase, t) |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | func testLoad(testCase loadTestCase, t *testing.T) { |
| 62 | defer func() { |