Add flag parsing test for api --template
This commit is contained in:
parent
07cb5e9e17
commit
0f27084f57
1 changed files with 31 additions and 0 deletions
|
|
@ -47,6 +47,7 @@ func Test_NewCmdApi(t *testing.T) {
|
|||
Paginate: false,
|
||||
Silent: false,
|
||||
CacheTTL: 0,
|
||||
Template: "",
|
||||
},
|
||||
wantsErr: false,
|
||||
},
|
||||
|
|
@ -66,6 +67,7 @@ func Test_NewCmdApi(t *testing.T) {
|
|||
Paginate: false,
|
||||
Silent: false,
|
||||
CacheTTL: 0,
|
||||
Template: "",
|
||||
},
|
||||
wantsErr: false,
|
||||
},
|
||||
|
|
@ -85,6 +87,7 @@ func Test_NewCmdApi(t *testing.T) {
|
|||
Paginate: false,
|
||||
Silent: false,
|
||||
CacheTTL: 0,
|
||||
Template: "",
|
||||
},
|
||||
wantsErr: false,
|
||||
},
|
||||
|
|
@ -104,6 +107,7 @@ func Test_NewCmdApi(t *testing.T) {
|
|||
Paginate: false,
|
||||
Silent: false,
|
||||
CacheTTL: 0,
|
||||
Template: "",
|
||||
},
|
||||
wantsErr: false,
|
||||
},
|
||||
|
|
@ -123,6 +127,7 @@ func Test_NewCmdApi(t *testing.T) {
|
|||
Paginate: true,
|
||||
Silent: false,
|
||||
CacheTTL: 0,
|
||||
Template: "",
|
||||
},
|
||||
wantsErr: false,
|
||||
},
|
||||
|
|
@ -142,6 +147,7 @@ func Test_NewCmdApi(t *testing.T) {
|
|||
Paginate: false,
|
||||
Silent: true,
|
||||
CacheTTL: 0,
|
||||
Template: "",
|
||||
},
|
||||
wantsErr: false,
|
||||
},
|
||||
|
|
@ -166,6 +172,7 @@ func Test_NewCmdApi(t *testing.T) {
|
|||
Paginate: true,
|
||||
Silent: false,
|
||||
CacheTTL: 0,
|
||||
Template: "",
|
||||
},
|
||||
wantsErr: false,
|
||||
},
|
||||
|
|
@ -190,6 +197,7 @@ func Test_NewCmdApi(t *testing.T) {
|
|||
Paginate: false,
|
||||
Silent: false,
|
||||
CacheTTL: 0,
|
||||
Template: "",
|
||||
},
|
||||
wantsErr: false,
|
||||
},
|
||||
|
|
@ -214,6 +222,7 @@ func Test_NewCmdApi(t *testing.T) {
|
|||
Paginate: false,
|
||||
Silent: false,
|
||||
CacheTTL: 0,
|
||||
Template: "",
|
||||
},
|
||||
wantsErr: false,
|
||||
},
|
||||
|
|
@ -233,6 +242,27 @@ func Test_NewCmdApi(t *testing.T) {
|
|||
Paginate: false,
|
||||
Silent: false,
|
||||
CacheTTL: time.Minute * 5,
|
||||
Template: "",
|
||||
},
|
||||
wantsErr: false,
|
||||
},
|
||||
{
|
||||
name: "with template",
|
||||
cli: "user -t 'hello {{.name}}'",
|
||||
wants: ApiOptions{
|
||||
Hostname: "",
|
||||
RequestMethod: "GET",
|
||||
RequestMethodPassed: false,
|
||||
RequestPath: "user",
|
||||
RequestInputFile: "",
|
||||
RawFields: []string(nil),
|
||||
MagicFields: []string(nil),
|
||||
RequestHeaders: []string(nil),
|
||||
ShowResponseHeaders: false,
|
||||
Paginate: false,
|
||||
Silent: false,
|
||||
CacheTTL: 0,
|
||||
Template: "hello {{.name}}",
|
||||
},
|
||||
wantsErr: false,
|
||||
},
|
||||
|
|
@ -270,6 +300,7 @@ func Test_NewCmdApi(t *testing.T) {
|
|||
assert.Equal(t, tt.wants.Paginate, opts.Paginate)
|
||||
assert.Equal(t, tt.wants.Silent, opts.Silent)
|
||||
assert.Equal(t, tt.wants.CacheTTL, opts.CacheTTL)
|
||||
assert.Equal(t, tt.wants.Template, opts.Template)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue