mirror of
https://github.com/ossf/scorecard.git
synced 2024-11-04 03:52:31 +03:00
Fix e2e branch (#1835)
This commit is contained in:
parent
eedd16d5be
commit
91202855fd
@ -33,6 +33,8 @@ var _ = Describe("E2E TEST: githubrepo.branchesHandler", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
Context("E2E TEST: Validate query cost", func() {
|
Context("E2E TEST: Validate query cost", func() {
|
||||||
|
skipIfTokenIsNot(githubWorkflowDefaultTokenType, "GITHUB_TOKEN only")
|
||||||
|
|
||||||
It("Should not have increased for HEAD query", func() {
|
It("Should not have increased for HEAD query", func() {
|
||||||
repourl := &repoURL{
|
repourl := &repoURL{
|
||||||
owner: "ossf",
|
owner: "ossf",
|
||||||
|
@ -16,6 +16,7 @@ package githubrepo
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
@ -39,6 +40,21 @@ func TestGithubrepo(t *testing.T) {
|
|||||||
|
|
||||||
var graphClient *githubv4.Client
|
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() {
|
var _ = BeforeSuite(func() {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
logger := log.NewLogger(log.DebugLevel)
|
logger := log.NewLogger(log.DebugLevel)
|
||||||
@ -47,4 +63,14 @@ var _ = BeforeSuite(func() {
|
|||||||
Transport: rt,
|
Transport: rt,
|
||||||
}
|
}
|
||||||
graphClient = githubv4.NewClient(httpClient)
|
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))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user