MCPcopy Index your code
hub / github.com/docker/docker-agent / TestRemoveDiscardsDirtyWork

Function TestRemoveDiscardsDirtyWork

pkg/worktree/worktree_test.go:293–307  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

291}
292
293func TestRemoveDiscardsDirtyWork(t *testing.T) {
294 t.Parallel()
295 dir := bootstrapRepo(t)
296
297 wt, err := Create(t.Context(), dir, "dirty", WithRoot(t.TempDir()))
298 require.NoError(t, err)
299 // Uncommitted change + untracked file + a new commit: removal must
300 // still succeed and wipe everything.
301 require.NoError(t, os.WriteFile(filepath.Join(wt.Dir, "a.txt"), []byte("changed"), 0o644))
302 runGit(t, wt.Dir, "commit", "-am", "work")
303 require.NoError(t, os.WriteFile(filepath.Join(wt.Dir, "untracked.txt"), []byte("x"), 0o644))
304
305 require.NoError(t, wt.Remove(t.Context()))
306 assert.NoDirExists(t, wt.Dir)
307}
308
309func bootstrapRepo(t *testing.T) string {
310 t.Helper()

Callers

nothing calls this directly

Calls 6

CreateFunction · 0.85
WithRootFunction · 0.85
ContextMethod · 0.80
bootstrapRepoFunction · 0.70
runGitFunction · 0.70
RemoveMethod · 0.45

Tested by

no test coverage detected