Skip to content

Add git-clone integration tests#104

Open
tnevrlka wants to merge 1 commit intokonflux-ci:mainfrom
tnevrlka:git-integration-tests
Open

Add git-clone integration tests#104
tnevrlka wants to merge 1 commit intokonflux-ci:mainfrom
tnevrlka:git-integration-tests

Conversation

@tnevrlka
Copy link
Copy Markdown
Contributor

Add integration tests to run in a container

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>
@tnevrlka tnevrlka requested a review from a team as a code owner April 21, 2026 13:12
runGit(t, dir, "config", "user.name", "Test")
}

type testRepoInfo struct {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just root is confusing here.

},
url: "file:///workspace/repo.git",
args: []string{"--depth", "0", "--submodules=false"},
check: func(t *testing.T, root, stdout, stderr string) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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...)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will ExecuteBuildCli do the job? It allows running the command in debug mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants