Conversation
Add integration tests to run in a container Assisted-by: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Tomáš Nevrlka <tnevrlka@redhat.com>
| runGit(t, dir, "config", "user.name", "Test") | ||
| } | ||
|
|
||
| type testRepoInfo struct { |
There was a problem hiding this comment.
It's still package wide, so better use testGitRepoInfo
| TagCommit string | ||
| } | ||
|
|
||
| // createLocalTestRepo creates a repo with 2 commits, tag v1.0.0 on first, dir-a/ and dir-b/. |
There was a problem hiding this comment.
nitpick: without looking into code dir-a/ and dir-b/ is not clear.
| } | ||
|
|
||
| // prepareMergeBranchBareRepo creates a bare repo with diverged main and feature branches. | ||
| func prepareMergeBranchBareRepo(t *testing.T, root string) { |
There was a problem hiding this comment.
Should it be named like prepareBareRepoWithFeatureBranch to be consistent with prepareBareRepoWithExternalSymlink?
| } | ||
|
|
||
| // prepareSubmoduleBareRepos creates a main repo with one submodule as bare repos. Returns HEAD commit. | ||
| func prepareSubmoduleBareRepos(t *testing.T, root string) string { |
There was a problem hiding this comment.
The name puzzled me at first. Does it make sense to make it consistent and name like prepareBareRepoWithSubmodule?
| } | ||
|
|
||
| // startGitCloneContainer starts a container with root bind-mounted at /workspace. | ||
| func startGitCloneContainer(t *testing.T, root string) *TestRunnerContainer { |
| }, | ||
| url: "file:///workspace/repo.git", | ||
| args: []string{"--depth", "0", "--submodules=false"}, | ||
| check: func(t *testing.T, root, stdout, stderr string) { |
There was a problem hiding this comment.
We need to ensure that it's not a shallow clone.
| setup: func(t *testing.T, root string) { | ||
| repo := createLocalTestRepo(t) | ||
| bareCloneToPath(t, repo.Path, filepath.Join(root, "repo.git")) | ||
| Expect(os.WriteFile(filepath.Join(root, "expected-commit"), []byte(repo.TagCommit), 0644)).To(Succeed()) |
There was a problem hiding this comment.
It doesn't look good nor safe to me.
A filed / sub-struct in tests OR setup returns []string and check takes it as an arg would be better.
| container := startGitCloneContainer(t, root) | ||
|
|
||
| args := append([]string{"git-clone", "--url", tc.url, "--output-dir", "/workspace/out", "--ssl-verify=false"}, tc.args...) | ||
| stdout, stderr, err := container.ExecuteCommandWithOutput(KonfluxBuildCli, args...) |
There was a problem hiding this comment.
Will ExecuteBuildCli do the job? It allows running the command in debug mode.
Add integration tests to run in a container