-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.go
62 lines (50 loc) · 893 Bytes
/
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
package main
import (
"errors"
"github.com/dstmodders/mod-cli/tools"
)
type Test struct {
canRunBusted bool
cfg *Config
tools *tools.Tools
}
func NewTest(cfg *Config) (*Test, error) {
t, err := tools.New()
if err != nil {
return nil, err
}
return &Test{
cfg: cfg,
tools: t,
}, nil
}
func (t *Test) checkTools() {
var errBusted error
//nolint:stylecheck
//goland:noinspection ALL
err := errors.New("Busted is not available")
errBusted = checkIfToolExists(t.tools.Docker, t.tools.Busted)
if errBusted == nil {
t.canRunBusted = true
err = nil
}
if t.canRunBusted {
if errBusted != nil {
printWarning(errBusted)
}
}
if err != nil {
fatalError(err)
}
}
func (t *Test) runBusted() error {
_, err := t.tools.Busted.Test()
if err != nil {
return err
}
return nil
}
func (t *Test) run() {
t.checkTools()
_ = t.runBusted()
}