MCPcopy
hub / github.com/docker/compose / TestEventOrdering

Function TestEventOrdering

pkg/watch/notify_test.go:65–96  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

63}
64
65func TestEventOrdering(t *testing.T) {
66 if runtime.GOOS == "windows" {
67 // https://qualapps.blogspot.com/2010/05/understanding-readdirectorychangesw_19.html
68 t.Skip("Windows doesn't make great guarantees about duplicate/out-of-order events")
69 return
70 }
71 f := newNotifyFixture(t)
72
73 count := 8
74 dirs := make([]string, count)
75 for i := range dirs {
76 dir := f.TempDir("watched")
77 dirs[i] = dir
78 f.watch(dir)
79 }
80
81 f.fsync()
82 f.events = nil
83
84 var expected []string
85 for i, dir := range dirs {
86 base := fmt.Sprintf("%d.txt", i)
87 p := filepath.Join(dir, base)
88 err := os.WriteFile(p, []byte(base), os.FileMode(0o777))
89 if err != nil {
90 t.Fatal(err)
91 }
92 expected = append(expected, filepath.Join(dir, base))
93 }
94
95 f.assertEvents(expected...)
96}
97
98// Simulate a git branch switch that creates a bunch
99// of directories, creates files in them, then deletes

Callers

nothing calls this directly

Calls 6

newNotifyFixtureFunction · 0.85
TempDirMethod · 0.80
fsyncMethod · 0.80
WriteFileMethod · 0.80
assertEventsMethod · 0.80
watchMethod · 0.45

Tested by

no test coverage detected