This repository has been archived by the owner on Mar 10, 2021. It is now read-only.
forked from harbur/captain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
captain_test.go
84 lines (66 loc) · 1.6 KB
/
captain_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
package captain // import "github.com/harbur/captain"
import (
"testing"
"github.com/stretchr/testify/assert"
)
// Test Fixtures
var validApp = App{
Image: "",
Pre: []string{"echo running pre"},
Post: []string{"echo running post"},
}
var invalidApp = App{
Pre: []string{"nonexistingPreCommand"},
Post: []string{"nonexistingPostCommand"},
}
// Pre Command
func TestPre(t *testing.T) {
res := Pre(validApp)
assert.Nil(t, res, "No error returned")
}
func TestPreFail(t *testing.T) {
res := Pre(invalidApp)
assert.NotNil(t, res, "Error returned")
}
// Post Command
func TestPost(t *testing.T) {
res := Post(validApp)
assert.Nil(t, res, "No error returned")
}
func TestPostFail(t *testing.T) {
res := Post(invalidApp)
assert.NotNil(t, res, "Error returned")
}
// Build Command
func TestBuild(t *testing.T) {
var testConfig = readConfig(configFile(basedir + "/test/Simple/captain.yml"))
var buildOpts = BuildOptions{
Config: testConfig,
}
Build(buildOpts)
}
// Test Command
func TestTest(t *testing.T) {
var testConfig = readConfig(configFile(basedir + "/test/Simple/captain.yml"))
var buildOpts = BuildOptions{
Config: testConfig,
}
Test(buildOpts)
}
// Pull Command
func TestPullNoBranchTags(t *testing.T) {
var testConfig = readConfig(configFile(basedir + "/test/alpine/captain.yml"))
var buildOpts = BuildOptions{
Config: testConfig,
Branch_tags: false,
}
Pull(buildOpts)
}
// Purge Command
func TestPurge(t *testing.T) {
var testConfig = readConfig(configFile(basedir + "/test/alpine/captain.yml"))
var buildOpts = BuildOptions{
Config: testConfig,
}
Purge(buildOpts)
}