-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from semaphoreci/handle-broken-when-syntax
Handle broken when syntax
- Loading branch information
Showing
11 changed files
with
259 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package whencli | ||
|
||
import ( | ||
"testing" | ||
|
||
assert "github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test__ListInputs(t *testing.T) { | ||
expressions := []string{ | ||
"branch = 'master'", | ||
"change_in('lib')", | ||
"branch = ", | ||
} | ||
|
||
results, err := ListInputs(expressions) | ||
|
||
assert.Nil(t, err) | ||
assert.Equal(t, len(expressions), len(results)) | ||
assert.Equal(t, []ListInputsResult{ | ||
ListInputsResult{ | ||
Expression: expressions[0], | ||
Error: "", | ||
Inputs: fromJSON(`[{"name": "branch", "type": "keyword"}]`), | ||
}, | ||
ListInputsResult{ | ||
Expression: expressions[1], | ||
Error: "", | ||
Inputs: fromJSON(`[{"name": "change_in", "params": ["lib"], "type": "fun"}]`), | ||
}, | ||
ListInputsResult{ | ||
Expression: expressions[2], | ||
Error: "Invalid or incomplete expression at the end of the line.", | ||
Inputs: fromJSON(`[]`), | ||
}, | ||
}, results) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package whencli | ||
|
||
import ( | ||
"testing" | ||
|
||
assert "github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test__Reduce(t *testing.T) { | ||
expressions := []string{ | ||
"branch = 'master'", | ||
"change_in('lib')", | ||
} | ||
|
||
inputs := []ReduceInputs{ | ||
ReduceInputs{ | ||
Keywords: map[string]interface{}{ | ||
"branch": "master", | ||
}, | ||
Functions: []interface{}{}, | ||
}, | ||
ReduceInputs{ | ||
Keywords: map[string]interface{}{}, | ||
Functions: []interface{}{ | ||
fromJSON(`{"name": "change_in", "params": ["lib"], "result": false}`), | ||
}, | ||
}, | ||
ReduceInputs{ | ||
Keywords: map[string]interface{}{}, | ||
Functions: []interface{}{}, | ||
}, | ||
} | ||
|
||
results, err := Reduce(expressions, inputs) | ||
|
||
assert.Nil(t, err) | ||
assert.Equal(t, len(expressions), len(results)) | ||
|
||
assert.Equal(t, []string{ | ||
"true", | ||
"false", | ||
}, results) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package whencli | ||
|
||
import gabs "github.com/Jeffail/gabs/v2" | ||
|
||
func fromJSON(s string) *gabs.Container { | ||
res, err := gabs.ParseJSON([]byte(s)) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
return res | ||
} |
Oops, something went wrong.