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

Function TestCreateWithBaseBranchesFromRef

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

Source from the content-addressed store, hash-verified

49}
50
51func TestCreateWithBaseBranchesFromRef(t *testing.T) {
52 t.Parallel()
53 dir := bootstrapRepo(t)
54
55 // Add a second commit on a side branch; the default HEAD (main) stays at
56 // the first commit.
57 runGit(t, dir, "branch", "feature")
58 runGit(t, dir, "checkout", "feature")
59 require.NoError(t, os.WriteFile(filepath.Join(dir, "b.txt"), []byte("B"), 0o644))
60 runGit(t, dir, "add", ".")
61 runGit(t, dir, "commit", "-m", "feature work")
62 featureHead := gitOut(t, dir, "rev-parse", "feature")
63 runGit(t, dir, "checkout", "-")
64
65 wt, err := Create(t.Context(), dir, "from-feature", WithRoot(t.TempDir()), WithBase("feature"))
66 require.NoError(t, err)
67
68 // The worktree branched from feature, so it carries feature's commit and
69 // its file.
70 assert.Equal(t, featureHead, gitOut(t, wt.Dir, "rev-parse", "HEAD"))
71 assert.FileExists(t, filepath.Join(wt.Dir, "b.txt"))
72 assert.Equal(t, featureHead, wt.BaseCommit)
73}
74
75func TestCreateWithEmptyBaseUsesHead(t *testing.T) {
76 t.Parallel()

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected