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

Function TestRepositoryLog

environment/integration/repository_test.go:133–169  ·  view source on GitHub ↗

TestRepositoryLog tests retrieving commit history for an environment

(t *testing.T)

Source from the content-addressed store, hash-verified

131
132// TestRepositoryLog tests retrieving commit history for an environment
133func TestRepositoryLog(t *testing.T) {
134 t.Parallel()
135 WithRepository(t, "repository-log", SetupEmptyRepo, func(t *testing.T, repo *repository.Repository, user *UserActions) {
136 ctx := context.Background()
137
138 // Create an environment and add some commits
139 env := user.CreateEnvironment("Test Log", "Testing repository log")
140 user.FileWrite(env.ID, "file1.txt", "initial content", "Initial commit")
141 user.FileWrite(env.ID, "file1.txt", "updated content", "Update file")
142 user.FileWrite(env.ID, "file2.txt", "new file", "Add second file")
143
144 // Get commit log without patches
145 var logBuf bytes.Buffer
146 err := repo.Log(ctx, env.ID, false, &logBuf)
147 logOutput := logBuf.String()
148 require.NoError(t, err, logOutput)
149
150 // Verify commit messages are present
151 assert.Contains(t, logOutput, "Add second file")
152 assert.Contains(t, logOutput, "Update file")
153 assert.Contains(t, logOutput, "Initial commit")
154
155 // Get commit log with patches
156 logBuf.Reset()
157 err = repo.Log(ctx, env.ID, true, &logBuf)
158 logWithPatchOutput := logBuf.String()
159 require.NoError(t, err, logWithPatchOutput)
160
161 // Verify patch information is included
162 assert.Contains(t, logWithPatchOutput, "diff --git")
163 assert.Contains(t, logWithPatchOutput, "+updated content")
164
165 // Test log for non-existent environment
166 err = repo.Log(ctx, "non-existent-env", false, &logBuf)
167 assert.Error(t, err)
168 })
169}
170
171// TestRepositoryCreateFromGitRef tests creating environments from specific git references
172func TestRepositoryCreateFromGitRef(t *testing.T) {

Callers

nothing calls this directly

Calls 5

WithRepositoryFunction · 0.85
LogMethod · 0.80
CreateEnvironmentMethod · 0.45
FileWriteMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected