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

Function TestCreateWorktree

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

Source from the content-addressed store, hash-verified

11)
12
13func TestCreateWorktree(t *testing.T) {
14 t.Parallel()
15 dir := bootstrapRepo(t)
16 root := t.TempDir()
17
18 wt, err := Create(t.Context(), dir, "", WithRoot(root))
19 require.NoError(t, err)
20 require.NotNil(t, wt)
21
22 assert.DirExists(t, wt.Dir)
23 // A random name looks like "focused_turing" (adjective_surname).
24 assert.Regexp(t, `^[a-z]+_[a-z]+$`, wt.Name)
25 assert.Equal(t, "worktree-"+wt.Name, wt.Branch)
26 assert.Equal(t, filepath.Join(root, "worktrees", wt.Name), wt.Dir)
27
28 // The worktree shares the repository's history: the initial commit's
29 // files must be present in the new working directory.
30 assert.FileExists(t, filepath.Join(wt.Dir, "a.txt"))
31
32 // The checked-out branch must match the one reported by the worktree.
33 out := gitOut(t, wt.Dir, "rev-parse", "--abbrev-ref", "HEAD")
34 assert.Equal(t, wt.Branch, out)
35}
36
37func TestCreateWithName(t *testing.T) {
38 t.Parallel()

Callers

nothing calls this directly

Calls 5

CreateFunction · 0.85
WithRootFunction · 0.85
gitOutFunction · 0.85
ContextMethod · 0.80
bootstrapRepoFunction · 0.70

Tested by

no test coverage detected