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