Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix e2e branch #1835

Merged
merged 1 commit into from
Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clients/githubrepo/branches_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ var _ = Describe("E2E TEST: githubrepo.branchesHandler", func() {
})

Context("E2E TEST: Validate query cost", func() {
skipIfTokenIsNot(githubWorkflowDefaultTokenType, "GITHUB_TOKEN only")

It("Should not have increased for HEAD query", func() {
repourl := &repoURL{
owner: "ossf",
Expand Down
26 changes: 26 additions & 0 deletions clients/githubrepo/githubrepo_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package githubrepo

import (
"context"
"fmt"
"net/http"
"os"
"testing"
Expand All @@ -39,6 +40,21 @@ func TestGithubrepo(t *testing.T) {

var graphClient *githubv4.Client

type tokenType int

const (
patTokenType tokenType = iota
githubWorkflowDefaultTokenType
)

var tokType tokenType

func skipIfTokenIsNot(t tokenType, msg string) {
if tokType != t {
Skip(msg)
}
}

var _ = BeforeSuite(func() {
ctx := context.Background()
logger := log.NewLogger(log.DebugLevel)
Expand All @@ -47,4 +63,14 @@ var _ = BeforeSuite(func() {
Transport: rt,
}
graphClient = githubv4.NewClient(httpClient)

tt := os.Getenv("TOKEN_TYPE")
switch tt {
case "PAT":
tokType = patTokenType
case "GITHUB_TOKEN":
tokType = githubWorkflowDefaultTokenType
default:
panic(fmt.Sprintf("invald TOKEN_TYPE: %s", tt))
}
})