18
18
package e2e
19
19
20
20
import (
21
+
"bytes"
21
22
"path/filepath"
22
23
24
+
"github.com/ksonnet/ksonnet/pkg/util/table"
23
25
. "github.com/onsi/ginkgo"
26
+
. "github.com/onsi/gomega"
24
27
)
25
28
26
29
var _ = Describe("ks import", func() {
27
-
var a app
30
+
var (
31
+
a app
32
+
importPath string
33
+
isErr bool
34
+
o *output
35
+
)
28
36
29
37
BeforeEach(func() {
30
38
a = e.initApp(nil)
31
39
a.generateDeployedService()
40
+
isErr = false
41
+
})
42
+
43
+
JustBeforeEach(func() {
44
+
o = a.runKs("import", "-f", importPath)
45
+
if isErr {
46
+
assertExitStatus(o, 1)
47
+
return
48
+
}
49
+
50
+
assertExitStatus(o, 0)
32
51
})
33
52
34
53
Context("directory", func() {
54
+
BeforeEach(func() {
55
+
importPath = filepath.Join(e.wd(), "testdata", "input", "import")
56
+
})
57
+
35
58
It("imports the files in the directory", func() {
36
-
path := filepath.Join(e.wd(), "testdata", "input", "import")
37
-
o := a.runKs("import", "-f", path)
38
-
assertExitStatus(o, 0)
59
+
names := a.componentNames()
60
+
61
+
var buf bytes.Buffer
62
+
t := table.New(&buf)
63
+
t.SetHeader([]string{"component"})
64
+
for _, name := range names {
65
+
t.Append([]string{name})
66
+
}
67
+
Expect(t.Render()).NotTo(HaveOccurred())
39
68
40
69
o = a.componentList()
41
-
assertOutput("import/output.txt", o.stdout)
70
+
Expect(o.stdout).To(Equal(buf.String()))
42
71
})
43
72
})
44
73
45
74
Context("file", func() {
75
+
BeforeEach(func() {
76
+
importPath = filepath.Join(e.wd(), "testdata", "input", "import", "deployment.yaml")
77
+
})
78
+
46
79
It("imports the file", func() {
47
-
path := filepath.Join(e.wd(), "testdata", "input", "import", "deployment.yaml")
48
-
o := a.runKs("import", "-f", path)
49
-
assertExitStatus(o, 0)
80
+
names := a.componentNames()
81
+
82
+
var buf bytes.Buffer
83
+
t := table.New(&buf)
84
+
t.SetHeader([]string{"component"})
85
+
for _, name := range names {
86
+
t.Append([]string{name})
87
+
}
88
+
Expect(t.Render()).NotTo(HaveOccurred())
50
89
51
90
o = a.componentList()
52
-
assertOutput("import/output.txt", o.stdout)
91
+
Expect(o.stdout).To(Equal(buf.String()))
53
92
})
54
93
})
55
94
56
95
Context("invalid path", func() {
96
+
BeforeEach(func() {
97
+
importPath = filepath.Join(e.wd(), "testdata", "input", "import", "invalid.yaml")
98
+
isErr = true
99
+
})
100
+
57
101
It("returns an error", func() {
58
-
path := filepath.Join(e.wd(), "testdata", "input", "import", "invalid.yaml")
59
-
o := a.runKs("import", "-f", path)
60
-
assertExitStatus(o, 1)
61
102
assertOutputContains("import/invalid.txt", o.stderr)
62
103
})
63
104
})
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4