forked from aliyun/aliyun-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flags_test.go
79 lines (64 loc) · 3.12 KB
/
flags_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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Copyright (c) 2009-present, Alibaba Cloud All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package openapi
import (
"testing"
"github.com/aliyun/aliyun-cli/cli"
"github.com/aliyun/aliyun-cli/i18n"
"github.com/stretchr/testify/assert"
)
func TestAFlags(t *testing.T) {
i18n.SetLanguage("en")
flagset := cli.NewFlagSet()
AddFlags(flagset)
secureflag := SecureFlag(flagset)
assert.Equal(t, "secure", secureflag.Name)
assert.Equal(t, "use `--secure` to force https", secureflag.Short.Text())
forceflag := ForceFlag(flagset)
assert.Equal(t, "force", forceflag.Name)
assert.Equal(t, "use `--force` to skip api and parameters check", forceflag.Short.Text())
endpointflag := EndpointFlag(flagset)
assert.Equal(t, "endpoint", endpointflag.Name)
assert.Equal(t, "use `--endpoint <endpoint>` to assign endpoint", endpointflag.Short.Text())
versionflag := VersionFlag(flagset)
assert.Equal(t, "version", versionflag.Name)
assert.Equal(t, "use `--version <YYYY-MM-DD>` to assign product api version", versionflag.Short.Text())
headerflag := HeaderFlag(flagset)
assert.Equal(t, "header", headerflag.Name)
assert.Equal(t, "use `--header X-foo=bar` to add custom HTTP header, repeatable", headerflag.Short.Text())
bodyflag := BodyFlag(flagset)
assert.Equal(t, "body", bodyflag.Name)
assert.Equal(t, "use `--body $(cat foo.json)` to assign http body in RESTful call", bodyflag.Short.Text())
bodyfileflag := BodyFileFlag(flagset)
assert.Equal(t, "body-file", bodyfileflag.Name)
assert.Equal(t, "assign http body in Restful call with local file", bodyfileflag.Short.Text())
acceptflag := AcceptFlag(flagset)
assert.Equal(t, "accept", acceptflag.Name)
assert.Equal(t, "add `--accept {json|xml}` to add Accept header", acceptflag.Short.Text())
roaflag := RoaFlag(flagset)
assert.Equal(t, "roa", roaflag.Name)
assert.Equal(t, "use `--roa {GET|PUT|POST|DELETE}` to assign restful call.[DEPRECATED]", roaflag.Short.Text())
dryrunflag := DryRunFlag(flagset)
assert.Equal(t, "dryrun", dryrunflag.Name)
assert.Equal(t, "add `--dryrun` to validate and print request without running.", dryrunflag.Short.Text())
quietflag := QuietFlag(flagset)
assert.Equal(t, "quiet", quietflag.Name)
assert.Equal(t, "add `--quiet` to hide normal output", quietflag.Short.Text())
outputflag := OutputFlag(flagset)
assert.Equal(t, "output", outputflag.Name)
assert.Equal(t, "use `--output cols=Field1,Field2 [rows=jmesPath]` to print output as table", outputflag.Short.Text())
methodflag := MethodFlag(flagset)
assert.Equal(t, "method", methodflag.Name)
assert.Equal(t, "add `--method {GET|POST}` to assign rpc call method.", methodflag.Short.Text())
}