MCPcopy
hub / github.com/dagger/container-use / TestRepositoryCheckout

Function TestRepositoryCheckout

environment/integration/repository_test.go:108–130  ·  view source on GitHub ↗

TestRepositoryCheckout tests checking out an environment branch

(t *testing.T)

Source from the content-addressed store, hash-verified

106
107// TestRepositoryCheckout tests checking out an environment branch
108func TestRepositoryCheckout(t *testing.T) {
109 t.Parallel()
110 WithRepository(t, "repository-checkout", SetupEmptyRepo, func(t *testing.T, repo *repository.Repository, user *UserActions) {
111 ctx := context.Background()
112
113 // Create an environment and add content
114 env := user.CreateEnvironment("Test Checkout", "Testing repository checkout")
115 user.FileWrite(env.ID, "test.txt", "test content", "Add test file")
116
117 // Checkout the environment branch in the source repo
118 branch, err := repo.Checkout(ctx, env.ID, "")
119 require.NoError(t, err)
120 assert.NotEmpty(t, branch)
121
122 // Verify we're on the correct branch
123 currentBranch, err := repository.RunGitCommand(ctx, repo.SourcePath(), "branch", "--show-current")
124 require.NoError(t, err)
125 // Branch name could be either env.ID or cu-env.ID depending on the logic
126 actualBranch := strings.TrimSpace(currentBranch)
127 assert.True(t, actualBranch == env.ID || actualBranch == "cu-"+env.ID,
128 "Expected branch to be %s or cu-%s, got %s", env.ID, env.ID, actualBranch)
129 })
130}
131
132// TestRepositoryLog tests retrieving commit history for an environment
133func TestRepositoryLog(t *testing.T) {

Callers

nothing calls this directly

Calls 6

RunGitCommandFunction · 0.92
WithRepositoryFunction · 0.85
CheckoutMethod · 0.80
SourcePathMethod · 0.80
CreateEnvironmentMethod · 0.45
FileWriteMethod · 0.45

Tested by

no test coverage detected