Skip to content

feat(agent/agentcontainers): add file watcher and dirty status #17573

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Apr 29, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix test setup/clock advancement
  • Loading branch information
mafredri committed Apr 28, 2025
commit 58a70e8d2f9d0e637f59359e85d763241bd591fb
7 changes: 6 additions & 1 deletion agent/agentcontainers/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,13 +652,18 @@ func TestAPI(t *testing.T) {
assert.Contains(t, fWatcher.addedPaths, configPath,
"watcher should be watching the container's config file")

// Make sure the start loop has been called.
fWatcher.waitNext(ctx)

// Send a file modification event and check if the container is
// marked dirty.
fWatcher.sendEventWaitNextCalled(ctx, fsnotify.Event{
Name: configPath,
Op: fsnotify.Write,
})

mClock.Advance(time.Minute).MustWait(ctx)

// Check if the container is marked as dirty.
req = httptest.NewRequest(http.MethodGet, "/devcontainers", nil)
rec = httptest.NewRecorder()
Expand All @@ -671,7 +676,7 @@ func TestAPI(t *testing.T) {
assert.True(t, response.Devcontainers[0].Dirty,
"container should be marked as dirty after config file was modified")

mClock.Advance(10 * time.Minute).MustWait(ctx)
mClock.Advance(time.Minute).MustWait(ctx)

container.ID = "new-container-id" // Simulate a new container ID after recreation.
container.FriendlyName = "new-container-name"
Expand Down
Loading