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

Function TestExists

pkg/devspace/config/loader/loader_test.go:35–76  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

33}
34
35func TestExists(t *testing.T) {
36 testCases := []existsTestCase{
37 {
38 name: "Only custom file name exists",
39 configPath: "mypath.yaml",
40 files: map[string]interface{}{
41 "mypath.yaml": "",
42 },
43 expectedanswer: true,
44 },
45 {
46 name: "Default file name does not exist",
47 files: map[string]interface{}{
48 "mypath.yaml": "",
49 },
50 expectedanswer: false,
51 },
52 }
53
54 dir := t.TempDir()
55
56 wdBackup, err := os.Getwd()
57 if err != nil {
58 t.Fatalf("Error getting current working directory: %v", err)
59 }
60 err = os.Chdir(dir)
61 if err != nil {
62 t.Fatalf("Error changing working directory: %v", err)
63 }
64
65 defer func() {
66 //Delete temp folder
67 err = os.Chdir(wdBackup)
68 if err != nil {
69 t.Fatalf("Error changing dir back: %v", err)
70 }
71 }()
72
73 for _, testCase := range testCases {
74 testExists(testCase, t)
75 }
76}
77
78func testExists(testCase existsTestCase, t *testing.T) {
79 defer func() {

Callers

nothing calls this directly

Calls 2

testExistsFunction · 0.85
FatalfMethod · 0.45

Tested by

no test coverage detected