Skip to content

Commit

Permalink
make e2e test gitlab testing on multiple providers
Browse files Browse the repository at this point in the history
Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
  • Loading branch information
chmouel committed Apr 20, 2022
1 parent 2278c6e commit 3c7a898
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
4 changes: 2 additions & 2 deletions test/gitlab_merge_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestGitlabMergeRequest(t *testing.T) {
err = tgitlab.CreateCRD(ctx, projectinfo, runcnx, targetNS)
assert.NilError(t, err)

entries, err := payload.GetEntries([]string{"testdata/pipelinerun.yaml"}, targetNS, projectinfo.DefaultBranch,
entries, err := payload.GetEntries([]string{"testdata/pipelinerun.yaml", "testdata/pipelinerun-clone.yaml"}, targetNS, projectinfo.DefaultBranch,
options.PullRequestEvent)
assert.NilError(t, err)

Expand All @@ -49,7 +49,7 @@ func TestGitlabMergeRequest(t *testing.T) {
assert.NilError(t, err)
runcnx.Clients.Log.Infof("MergeRequest %s/-/merge_requests/%d has been created", projectinfo.WebURL, mrID)
defer tgitlab.TearDown(ctx, t, runcnx, glprovider, mrID, targetRefName, targetNS, opts.ProjectID)
wait.Succeeded(ctx, t, runcnx, opts, "Merge_Request", targetNS, 1, "", title)
wait.Succeeded(ctx, t, runcnx, opts, "Merge_Request", targetNS, 2, "", title)
}

// Local Variables:
Expand Down
27 changes: 15 additions & 12 deletions test/pkg/gitlab/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,21 @@ var (
)

func PushFilesToRef(client *ghlib.Client, commitMessage, baseBranch, targetRef string, pid int, files map[string]string) error {
for fileName, content := range files {
_, _, err := client.RepositoryFiles.CreateFile(pid, fileName, &ghlib.CreateFileOptions{
Branch: ghlib.String(targetRef),
StartBranch: ghlib.String(baseBranch),
AuthorEmail: ghlib.String(commitEmail),
AuthorName: ghlib.String(commitAuthor),
Content: ghlib.String(content),
CommitMessage: ghlib.String(commitMessage),
})
if err != nil {
return err
}
fullYaml := ""
for _, content := range files {
fullYaml += "---\n"
fullYaml += content
}
_, _, err := client.RepositoryFiles.CreateFile(pid, ".tekton/pr.yaml", &ghlib.CreateFileOptions{
Branch: ghlib.String(targetRef),
StartBranch: ghlib.String(baseBranch),
AuthorEmail: ghlib.String(commitEmail),
AuthorName: ghlib.String(commitAuthor),
Content: ghlib.String(fullYaml),
CommitMessage: ghlib.String(commitMessage),
})
if err != nil {
return err
}
return nil
}
Expand Down

0 comments on commit 3c7a898

Please sign in to comment.