forked from jfrog/frogbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
github_test.go
41 lines (34 loc) · 1.36 KB
/
github_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"github.com/jfrog/frogbot/v2/utils"
"github.com/jfrog/froggit-go/vcsclient"
"github.com/jfrog/froggit-go/vcsutils"
"github.com/stretchr/testify/assert"
"testing"
)
const (
githubIntegrationTokenEnv = "FROGBOT_TESTS_GITHUB_TOKEN"
githubGitCloneUrl = "https://github.com/frogbot-test/integration.git"
)
func buildGitHubClient(t *testing.T, githubToken string) vcsclient.VcsClient {
githubClient, err := vcsclient.NewClientBuilder(vcsutils.GitHub).Token(githubToken).Build()
assert.NoError(t, err)
return githubClient
}
func buildGitHubIntegrationTestDetails(t *testing.T) *IntegrationTestDetails {
integrationRepoToken := getIntegrationToken(t, githubIntegrationTokenEnv)
return NewIntegrationTestDetails(integrationRepoToken, string(utils.GitHub), githubGitCloneUrl, "frogbot-test")
}
func githubTestsInit(t *testing.T) (vcsclient.VcsClient, *IntegrationTestDetails) {
testDetails := buildGitHubIntegrationTestDetails(t)
githubClient := buildGitHubClient(t, testDetails.GitToken)
return githubClient, testDetails
}
func TestGitHub_ScanPullRequestIntegration(t *testing.T) {
githubClient, testDetails := githubTestsInit(t)
runScanPullRequestCmd(t, githubClient, testDetails)
}
func TestGitHub_ScanRepositoryIntegration(t *testing.T) {
githubClient, testDetails := githubTestsInit(t)
runScanRepositoryCmd(t, githubClient, testDetails)
}