-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain_test.go
94 lines (72 loc) · 2.22 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
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package main
import (
. "github.com/smartystreets/goconvey/convey"
"io/ioutil"
"os"
"testing"
)
var goodData = `
test:
override:
- ./vendor/bin/parallel-lint --exclude vendor .
- ./vendor/bin/phpunit -c phpunit.xml.dist
- ./vendor/bin/phpcs --standard=vendor/crowdcube/codesniffer-standard/Crowdcube -p --report=full --report-checkstyle=build/logs/checkstyle.xml --runtime-set ignore_warnings_on_exit true src/ lib/ tests/
`
var simpleData = `
test:
override:
- ./
- ./v
- ./ve
`
func TestUnderstandsYAML(t *testing.T) {
Convey("test reading and running tests", t, func() {
ioutil.WriteFile("/tmp/circle.yml", []byte(goodData), 0644)
circle := Circle{}
circle.Filename = "/tmp/circle.yml"
Convey("Should find testing -> override in YMAL", func() {
c := Circle{}
c.Test.Override = []string{"./", "./v", "./ve"}
c2 := Circle{}
err := c2.getCommandsFromYAML([]byte(simpleData))
So(c2, ShouldResemble, c)
So(err, ShouldBeEmpty)
})
Convey("Should log an error with bad YAML", func() {
err := circle.getCommandsFromYAML([]byte("sdkfjls"))
shouldBe := Circle{Filename: "/tmp/circle.yml"}
So(err, ShouldNotBeNil)
So(circle, ShouldResemble, shouldBe)
})
Convey("Circle.yml should not exist", func() {
So(doesFileExist("/tmp/for.baz"), ShouldEqual, false)
})
Convey("circle.yml should exist", func() {
So(doesFileExist("/tmp/circle.yml"), ShouldEqual, true)
})
Convey("Finding a circlefile should be good!", func() {
So(readFile("/tmp/circle.yml"), ShouldEqual, goodData)
})
Convey("clean vendor bin from string", func() {
So(cleanVendorBin("./vendor/bin/baz"), ShouldEqual, "./baz")
})
Convey("no need to clean vendor bin", func() {
So(cleanVendorBin("./bin/baz"), ShouldEqual, "./bin/baz")
})
Convey("run and echo a pwd command", func() {
c := "pwd"
err := executeCommands(c)
So(err, ShouldBeNil)
})
Convey("run a command with invalid arguments", func() {
So(executeCommands("pwd -e"), ShouldNotBeNil)
})
Convey("run all of the above", func() {
//Removeing this until we can have some sensible data in the good stuff
//So(circle.runTests(), ShouldBeNil)
})
Reset(func() {
os.Remove("/tmp/circle.yml")
})
})
}