forked from opencontrol/compliance-masonry
/
diff_test.go
42 lines (40 loc) · 1.25 KB
/
diff_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
package main
import (
"bytes"
"github.com/codegangsta/cli"
. "github.com/onsi/ginkgo"
"github.com/stretchr/testify/assert"
"path/filepath"
)
var _ = Describe("Diff", func() {
var (
app *cli.App
buffer *bytes.Buffer
errBuffer *bytes.Buffer
)
BeforeEach(func() {
app = NewCLIApp()
buffer = new(bytes.Buffer)
app.Writer = buffer
errBuffer = new(bytes.Buffer)
app.ErrWriter = errBuffer
cli.ErrWriter = errBuffer
cli.OsExiter = func(code int) {}
})
Describe("Running the diff command", func() {
It("should return an exit error of 1 when running without certification argument.", func() {
err := app.Run([]string{app.Name, "diff"})
assert.NotNil(GinkgoT(), err)
if assert.IsType(GinkgoT(), new(cli.ExitError), err) {
exitErr, _ := err.(*cli.ExitError)
assert.Equal(GinkgoT(), 1, exitErr.ExitCode())
assert.Contains(GinkgoT(), errBuffer.String(), "Error: Missing Certification Argument")
}
})
It("should return return the number a missing controls when given a certification", func() {
err := app.Run([]string{app.Name, "diff", "LATO", "-o", filepath.Join("fixtures", "opencontrol_fixtures")})
assert.Nil(GinkgoT(), err)
assert.Contains(GinkgoT(), buffer.String(), "Number of missing controls:")
})
})
})