Skip to content

Commit

Permalink
Merge pull request #5 from EGT-Ukraine/fix/variables
Browse files Browse the repository at this point in the history
variables fix
  • Loading branch information
Vyacheslav Pryimak authored Feb 13, 2019
2 parents b38645a + d6f7772 commit 1c73647
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion trigger/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func (p Trigger) schemaName(schema Schema) string {
func (p Trigger) urlVariables() url.Values {
values := url.Values{}
for _, variable := range p.variables {
kv := strings.Split(variable, ":")
kv := strings.SplitN(variable, ":", 2)
if len(kv) == 2 {
values.Add(fmt.Sprintf("variables[%s]", kv[0]), kv[1])
}
Expand Down
22 changes: 20 additions & 2 deletions trigger/trigger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,24 @@ func TestPipeline_variables(t *testing.T) {
"value2",
},
},
}, {
name: "success with double separator",
args: struct {
variables []string
}{
variables: []string{
"variable1:value1:prefix",
"variable2:value2:prefix",
},
},
want: map[string][]string{
"variables[variable1]": {
"value1:prefix",
},
"variables[variable2]": {
"value2:prefix",
},
},
}, {
name: "fail",
args: struct {
Expand All @@ -106,10 +124,10 @@ func TestPipeline_variables(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
p := &Trigger{variables: tt.args.variables}
if !tt.wantErr {
assert.Equal(t, p.urlVariables(), tt.want)
assert.Equal(t, tt.want, p.urlVariables())
return
}
assert.NotEqual(t, p.urlVariables(), tt.want)
assert.NotEqual(t, tt.want, p.urlVariables())
})
}
}

0 comments on commit 1c73647

Please sign in to comment.