forked from jfrog/frogbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
48 lines (41 loc) · 1.24 KB
/
main_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
package main
import (
"fmt"
"github.com/jfrog/frogbot/v2/utils"
"github.com/jfrog/jfrog-client-go/utils/log"
clientTests "github.com/jfrog/jfrog-client-go/utils/tests"
"io"
"os"
"strings"
"testing"
"github.com/stretchr/testify/assert"
)
var IntegrationTestPackages = []string{
"github.com/jfrog/frogbot/v2",
"github.com/jfrog/frogbot/v2/scanrepository",
"github.com/jfrog/frogbot/v2/scanpullrequest",
"github.com/jfrog/frogbot/v2/packagehandlers",
}
func TestUnitTests(t *testing.T) {
packages := clientTests.GetTestPackages("./...")
for _, integrationPackage := range IntegrationTestPackages {
packages = clientTests.ExcludeTestsPackage(packages, integrationPackage)
}
log.Info("Running Unit tests on the following packages:\n", strings.Join(packages, "\n"))
assert.NoError(t, clientTests.RunTests(packages, false))
}
func TestVersion(t *testing.T) {
originalStdout := os.Stdout
r, w, _ := os.Pipe()
defer func() {
os.Stdout = originalStdout
}()
os.Stdout = w
os.Args = []string{"frogbot", "--version"}
main()
assert.NoError(t, w.Close())
out, err := io.ReadAll(r)
assert.NoError(t, err)
expectedVersion := fmt.Sprintf("Frogbot version %s", utils.FrogbotVersion)
assert.Equal(t, expectedVersion, strings.TrimSpace(string(out)))
}