Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 58a70e8

Browse files
committed
fix test setup/clock advancement
1 parent 263c683 commit 58a70e8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

agent/agentcontainers/api_test.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -652,13 +652,18 @@ func TestAPI(t *testing.T) {
652652
assert.Contains(t, fWatcher.addedPaths, configPath,
653653
"watcher should be watching the container's config file")
654654

655+
// Make sure the start loop has been called.
656+
fWatcher.waitNext(ctx)
657+
655658
// Send a file modification event and check if the container is
656659
// marked dirty.
657660
fWatcher.sendEventWaitNextCalled(ctx, fsnotify.Event{
658661
Name: configPath,
659662
Op: fsnotify.Write,
660663
})
661664

665+
mClock.Advance(time.Minute).MustWait(ctx)
666+
662667
// Check if the container is marked as dirty.
663668
req = httptest.NewRequest(http.MethodGet, "/devcontainers", nil)
664669
rec = httptest.NewRecorder()
@@ -671,7 +676,7 @@ func TestAPI(t *testing.T) {
671676
assert.True(t, response.Devcontainers[0].Dirty,
672677
"container should be marked as dirty after config file was modified")
673678

674-
mClock.Advance(10 * time.Minute).MustWait(ctx)
679+
mClock.Advance(time.Minute).MustWait(ctx)
675680

676681
container.ID = "new-container-id" // Simulate a new container ID after recreation.
677682
container.FriendlyName = "new-container-name"

0 commit comments

Comments
 (0)