test: Add escapeArg testing (#116)

This commit is contained in:
Bo-Yi Wu 2018-02-27 14:58:43 +08:00 committed by GitHub
parent 7f4cb1c1d0
commit 8bfc58f9d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -273,3 +273,36 @@ func TestSyncMode(t *testing.T) {
err := plugin.Exec()
assert.Nil(t, err)
}
func Test_escapeArg(t *testing.T) {
type args struct {
arg string
}
tests := []struct {
name string
args args
want string
}{
{
name: "escape nothing",
args: args{
arg: "Hi I am appleboy",
},
want: `'Hi I am appleboy'`,
},
{
name: "escape single quote",
args: args{
arg: "Hi I am 'appleboy'",
},
want: `'Hi I am '\''appleboy'\'''`,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := escapeArg(tt.args.arg); got != tt.want {
t.Errorf("escapeArg() = %v, want %v", got, tt.want)
}
})
}
}