Skip to content

Commit

Permalink
🌱 Improve GitLab repo branches E2E test (#3362)
Browse files Browse the repository at this point in the history
- Add an E2E test to check the default branch of a GitLab repo
- Initialize the repo with the HEAD commit and 0 depth
- Check that the default branch is named "main"

[clients/gitlabrepo/branches_e2e_test.go]
- Add an E2E test to check the default branch of a GitLab repo
- Initialize the repo with the HEAD commit and 0 depth
- Check that the default branch is named "main"

Signed-off-by: naveensrinivasan <172697+naveensrinivasan@users.noreply.github.com>
  • Loading branch information
naveensrinivasan authored Aug 8, 2023
1 parent 719770c commit 28f8dd6
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions clients/gitlabrepo/branches_e2e_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright 2023 OpenSSF Scorecard Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package gitlabrepo

import (
"context"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

var _ = Describe("E2E TEST: gitlabrepo.Branches", func() {
Context("Test Default branch- GitLab", func() {
It("returns branches for the repo", func() {
skipIfTokenIsNot(gitlabPATTokenType, "GitLab only")
repo, err := MakeGitlabRepo("https://gitlab.com/ossf-test/scorecard")
Expect(err).Should(BeNil())

client, err := CreateGitlabClient(context.Background(), repo.Host())
Expect(err).Should(BeNil())

err = client.InitRepo(repo, "HEAD", 0)
Expect(err).Should(BeNil())
branch, err := client.GetDefaultBranch()
Expect(err).Should(BeNil())
Expect(branch.Name).Should(Equal("main"))
})
})
})

0 comments on commit 28f8dd6

Please sign in to comment.