MCPcopy Create free account
hub / github.com/devspace-sh/devspace / TestWatcher

Function TestWatcher

pkg/devspace/watch/watch_test.go:29–176  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

27}
28
29func TestWatcher(t *testing.T) {
30 watchedPaths := []string{".", "hello.txt", "watchedsubdir"}
31 testCases := []testCase{
32 {
33 name: "Create text file",
34 expectedChanges: []string{"hello.txt"},
35 changes: []testCaseChange{
36 {
37 path: "hello.txt",
38 content: "hello",
39 },
40 },
41 },
42 {
43 name: "Create file in folder",
44 expectedChanges: []string{"watchedsubdir"},
45 changes: []testCaseChange{
46 {
47 path: "watchedsubdir/unwatchedsubfile.txt",
48 content: "watchedsubdir",
49 },
50 },
51 },
52 {
53 name: "Override file",
54 expectedChanges: []string{"hello.txt"},
55 changes: []testCaseChange{
56 {
57 path: "hello.txt",
58 content: "another hello",
59 },
60 },
61 },
62 {
63 name: "Delete file",
64 expectedChanges: []string{},
65 expectedDeletions: []string{"hello.txt"},
66 changes: []testCaseChange{
67 {
68 path: "hello.txt",
69 delete: true,
70 },
71 },
72 },
73 }
74
75 // Create TmpFolder
76 dir := t.TempDir()
77
78 wdBackup, err := os.Getwd()
79 if err != nil {
80 t.Fatalf("Error getting current working directory: %v", err)
81 }
82 err = os.Chdir(dir)
83 if err != nil {
84 t.Fatalf("Error changing working directory: %v", err)
85 }
86

Callers

nothing calls this directly

Calls 11

GetInstanceFunction · 0.92
WriteToFileFunction · 0.92
LockMethod · 0.80
UnlockMethod · 0.80
indexOfFunction · 0.70
NewFunction · 0.70
StartMethod · 0.65
RemoveMethod · 0.65
StopMethod · 0.65
FatalfMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected