forked from jfrog/jfrog-cli-security
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jfrogclisecurity_test.go
51 lines (43 loc) · 1.28 KB
/
jfrogclisecurity_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
42
43
44
45
46
47
48
49
50
51
package main
import (
"flag"
"fmt"
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
"github.com/jfrog/jfrog-cli-core/v2/utils/log"
"github.com/jfrog/jfrog-cli-security/tests/utils"
configTests "github.com/jfrog/jfrog-cli-security/tests"
clientLog "github.com/jfrog/jfrog-client-go/utils/log"
"os"
"testing"
)
func TestMain(m *testing.M) {
setupIntegrationTests()
result := m.Run()
tearDownIntegrationTests()
os.Exit(result)
}
func setupIntegrationTests() {
// Disable usage report.
if err := os.Setenv(coreutils.ReportUsage, "false"); err != nil {
clientLog.Error(fmt.Sprintf("Couldn't set env: %s. Error: %s", coreutils.ReportUsage, err.Error()))
os.Exit(1)
}
// Disable progress bar and confirmation messages.
if err := os.Setenv(coreutils.CI, "true"); err != nil {
clientLog.Error(fmt.Sprintf("Couldn't set env: %s. Error: %s", coreutils.CI, err.Error()))
os.Exit(1)
}
// General
flag.Parse()
log.SetDefaultLogger()
// Init
utils.InitTestCliDetails()
utils.AuthenticateArtifactory()
utils.AuthenticateXsc()
utils.CreateRequiredRepositories()
}
func tearDownIntegrationTests() {
// Important - Virtual repositories must be deleted first
utils.DeleteRepos(configTests.CreatedVirtualRepositories)
utils.DeleteRepos(configTests.CreatedNonVirtualRepositories)
}