TestRepositoryCheckout tests checking out an environment branch
(t *testing.T)
| 106 | |
| 107 | // TestRepositoryCheckout tests checking out an environment branch |
| 108 | func 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 |
| 133 | func TestRepositoryLog(t *testing.T) { |
nothing calls this directly
no test coverage detected