TestRepositoryLog tests retrieving commit history for an environment
(t *testing.T)
| 131 | |
| 132 | // TestRepositoryLog tests retrieving commit history for an environment |
| 133 | func 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 |
| 172 | func TestRepositoryCreateFromGitRef(t *testing.T) { |
nothing calls this directly
no test coverage detected