-
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.
test: create tests for retry message function
- Loading branch information
Showing
5 changed files
with
60 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package recipeutil_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/futurice/jalapeno/pkg/recipe" | ||
"github.com/futurice/jalapeno/pkg/recipeutil" | ||
"github.com/kylelemons/godebug/diff" | ||
) | ||
|
||
func TestMakeRetryMessage(t *testing.T) { | ||
testCases := []struct { | ||
Name string | ||
Args []string | ||
Values recipe.VariableValues | ||
Expected string | ||
}{ | ||
{ | ||
"No values", | ||
[]string{"jalapeno", "execute", "path/to/recipe"}, | ||
recipe.VariableValues{}, | ||
`To re-run the recipe with the same values, use the following command: | ||
jalapeno execute "path/to/recipe"`, | ||
}, | ||
{ | ||
"Non-empty values", | ||
[]string{"jalapeno", "execute", "path/to/recipe"}, | ||
recipe.VariableValues{ | ||
"key1": "value1", | ||
"key2": "value2", | ||
}, | ||
`To re-run the recipe with the same values, use the following command: | ||
jalapeno execute "path/to/recipe" --set "key1=value1" --set "key2=value2"`, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
t.Run(tc.Name, func(tt *testing.T) { | ||
result := recipeutil.MakeRetryMessage(tc.Args, tc.Values) | ||
if result != tc.Expected { | ||
tt.Errorf("%s", diff.Diff(tc.Expected, result)) | ||
} | ||
}) | ||
} | ||
} |