-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathoptions_test.go
74 lines (63 loc) · 2.24 KB
/
options_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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package ooze_test
import (
"regexp"
"testing"
"github.com/gtramontina/ooze"
"github.com/gtramontina/ooze/internal/cmdtestrunner"
"github.com/gtramontina/ooze/internal/fsrepository"
"github.com/gtramontina/ooze/viruses"
"github.com/gtramontina/ooze/viruses/integerincrement"
"github.com/gtramontina/ooze/viruses/loopbreak"
"github.com/stretchr/testify/assert"
)
//nolint:exhaustruct
func TestOptions(t *testing.T) {
t.Run("can configure repository root", func(t *testing.T) {
options := ooze.WithRepositoryRoot(".")(ooze.Options{})
assert.Equal(t, fsrepository.New("."), options.Repository)
})
t.Run("can configure test command to run", func(t *testing.T) {
{
options := ooze.WithTestCommand("yes")(ooze.Options{})
assert.Equal(t, cmdtestrunner.New("yes", []string{}...), options.TestRunner)
}
{
options := ooze.WithTestCommand("echo some value")(ooze.Options{})
assert.Equal(t, cmdtestrunner.New("echo", "some", "value"), options.TestRunner)
}
})
t.Run("can configure minimum threshold", func(t *testing.T) {
{
options := ooze.WithMinimumThreshold(0.25)(ooze.Options{})
assert.Equal(t, float32(0.25), options.MinimumThreshold)
}
{
options := ooze.WithMinimumThreshold(0.75)(ooze.Options{})
assert.Equal(t, float32(0.75), options.MinimumThreshold)
}
})
t.Run("can configure parallel", func(t *testing.T) {
options := ooze.Parallel()(ooze.Options{})
assert.Equal(t, true, options.Parallel)
})
t.Run("can configure source files to ignore", func(t *testing.T) {
{
options := ooze.IgnoreSourceFiles(".*")(ooze.Options{})
assert.Equal(t, []*regexp.Regexp{regexp.MustCompile(".*")}, options.IgnoreSourceFilesPatterns)
}
{
options := ooze.IgnoreSourceFiles(`.*\.go`)(ooze.Options{})
assert.Equal(t, []*regexp.Regexp{regexp.MustCompile(`.*\.go`)}, options.IgnoreSourceFilesPatterns)
}
})
t.Run("can configure viruses to infect source files", func(t *testing.T) {
{
options := ooze.WithViruses(loopbreak.New())(ooze.Options{})
assert.Equal(t, []viruses.Virus{loopbreak.New()}, options.Viruses)
}
{
options := ooze.WithViruses(loopbreak.New(), integerincrement.New())(ooze.Options{})
assert.Equal(t, []viruses.Virus{loopbreak.New(), integerincrement.New()}, options.Viruses)
}
})
}