本文整理汇总了Golang中github.com/codegangsta/cli.App.ErrWriter方法的典型用法代码示例。如果您正苦于以下问题:Golang App.ErrWriter方法的具体用法?Golang App.ErrWriter怎么用?Golang App.ErrWriter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/codegangsta/cli.App
的用法示例。
在下文中一共展示了App.ErrWriter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
"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")})