|
@@ -68,3 +68,89 @@ func TestExecNonExistant(t *testing.T) {
|
|
|
assert.Equal(t, int32(-1337), req.logEntry.ExitCode, "Log entry is set to an internal error code")
|
|
assert.Equal(t, int32(-1337), req.logEntry.ExitCode, "Log entry is set to an internal error code")
|
|
|
assert.Equal(t, "", req.logEntry.ActionIcon, "Log entry icon wasnt found")
|
|
assert.Equal(t, "", req.logEntry.ActionIcon, "Log entry icon wasnt found")
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+func TestArgumentNameCamelCase(t *testing.T) {
|
|
|
|
|
+ a1 := config.Action{
|
|
|
|
|
+ Title: "Do some tickles",
|
|
|
|
|
+ Shell: "echo 'Tickling {{ personName }}'",
|
|
|
|
|
+ Arguments: []config.ActionArgument{
|
|
|
|
|
+ {
|
|
|
|
|
+ Name: "personName",
|
|
|
|
|
+ Type: "ascii",
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ values := map[string]string {
|
|
|
|
|
+ "personName": "Fred",
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ out, err := parseActionArguments(a1.Shell, values, &a1);
|
|
|
|
|
+
|
|
|
|
|
+ assert.Equal(t, "echo 'Tickling Fred'", out);
|
|
|
|
|
+ assert.Nil(t, err)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func TestArgumentNameSnakeCase(t *testing.T) {
|
|
|
|
|
+ a1 := config.Action{
|
|
|
|
|
+ Title: "Do some tickles",
|
|
|
|
|
+ Shell: "echo 'Tickling {{ person_name }}'",
|
|
|
|
|
+ Arguments: []config.ActionArgument{
|
|
|
|
|
+ {
|
|
|
|
|
+ Name: "person_name",
|
|
|
|
|
+ Type: "ascii",
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ values := map[string]string {
|
|
|
|
|
+ "person_name": "Fred",
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ out, err := parseActionArguments(a1.Shell, values, &a1);
|
|
|
|
|
+
|
|
|
|
|
+ assert.Equal(t, "echo 'Tickling Fred'", out);
|
|
|
|
|
+ assert.Nil(t, err)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func TestArgumentNameNumbers(t *testing.T) {
|
|
|
|
|
+ a1 := config.Action{
|
|
|
|
|
+ Title: "Do some tickles",
|
|
|
|
|
+ Shell: "echo 'Tickling {{ person1name }}'",
|
|
|
|
|
+ Arguments: []config.ActionArgument{
|
|
|
|
|
+ {
|
|
|
|
|
+ Name: "person1name",
|
|
|
|
|
+ Type: "ascii",
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ values := map[string]string {
|
|
|
|
|
+ "person1name": "Fred",
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ out, err := parseActionArguments(a1.Shell, values, &a1);
|
|
|
|
|
+
|
|
|
|
|
+ assert.Equal(t, "echo 'Tickling Fred'", out);
|
|
|
|
|
+ assert.Nil(t, err)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func TestArgumentNotProvided(t *testing.T) {
|
|
|
|
|
+ a1 := config.Action{
|
|
|
|
|
+ Title: "Do some tickles",
|
|
|
|
|
+ Shell: "echo 'Tickling {{ personName }}'",
|
|
|
|
|
+ Arguments: []config.ActionArgument{
|
|
|
|
|
+ {
|
|
|
|
|
+ Name: "person",
|
|
|
|
|
+ Type: "ascii",
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ values := map[string]string {}
|
|
|
|
|
+
|
|
|
|
|
+ out, err := parseActionArguments(a1.Shell, values, &a1);
|
|
|
|
|
+
|
|
|
|
|
+ assert.Equal(t, "", out);
|
|
|
|
|
+ assert.Equal(t, err.Error(), "Required arg not provided: personName")
|
|
|
|
|
+}
|