forked from jfrog/frogbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitlab_test.go
41 lines (34 loc) · 1.36 KB
/
gitlab_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 (
gitlabIntegrationTokenEnv = "FROGBOT_TESTS_GITLAB_TOKEN"
gitlabGitCloneUrl = "https://gitlab.com/frogbot-test2/integration.git"
)
func buildGitLabClient(t *testing.T, gitlabToken string) vcsclient.VcsClient {
azureClient, err := vcsclient.NewClientBuilder(vcsutils.GitLab).Token(gitlabToken).Build()
assert.NoError(t, err)
return azureClient
}
func buildGitLabIntegrationTestDetails(t *testing.T) *IntegrationTestDetails {
integrationRepoToken := getIntegrationToken(t, gitlabIntegrationTokenEnv)
return NewIntegrationTestDetails(integrationRepoToken, string(utils.GitLab), gitlabGitCloneUrl, "frogbot-test2")
}
func gitlabTestsInit(t *testing.T) (vcsclient.VcsClient, *IntegrationTestDetails) {
testDetails := buildGitLabIntegrationTestDetails(t)
gitlabClient := buildGitLabClient(t, testDetails.GitToken)
return gitlabClient, testDetails
}
func TestGitLab_ScanPullRequestIntegration(t *testing.T) {
gitlabClient, testDetails := gitlabTestsInit(t)
runScanPullRequestCmd(t, gitlabClient, testDetails)
}
func TestGitLab_ScanRepositoryIntegration(t *testing.T) {
gitlabClient, testDetails := gitlabTestsInit(t)
runScanRepositoryCmd(t, gitlabClient, testDetails)
}