tests: Add cli.Context helper functions

Created two new helper functions to create a `cli.Context` with and without a
`cli.App`.

Calling these functions simplifies a lot of test code.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
This commit is contained in:
James O. D. Hunt
2018-08-09 14:15:07 +01:00
parent 41d1c14c68
commit 0ede467256
19 changed files with 147 additions and 214 deletions

View File

@@ -31,10 +31,9 @@ func TestVersion(t *testing.T) {
return testAppVersion
}
app := cli.NewApp()
ctx := cli.NewContext(app, nil, nil)
app.Name = testAppName
app.Version = runtimeVersion()
ctx := createCLIContext(nil)
ctx.App.Name = testAppName
ctx.App.Version = runtimeVersion()
fn, ok := versionCLICommand.Action.(func(context *cli.Context) error)
assert.True(t, ok)