-
-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add missing-key flag to manage behavior in case of non-existing key (#…
…1949) * Add missing-key flag to manage behavior in case of non-existing key * Fix typo * Added integration tests, added "default" to the allowed values for the missing-key flag * Use the "error" value for the MissingKey if it passes as empty string * Remove unnecessary writeFile from test * Add docs for the missin key feature * Add invalid to the allowed values of missing-key option * Remove unnecesary code from tests * Fix failed tests and linter errors * Update docs/content/usage.md Co-authored-by: Dave Henderson <[email protected]> * Update feature description * Add missing dot --------- Co-authored-by: Aleksandr Paramonov <[email protected]> Co-authored-by: Dave Henderson <[email protected]>
- Loading branch information
1 parent
886c3b2
commit f837061
Showing
12 changed files
with
172 additions
and
5 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
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,25 @@ | ||
package integration | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestMissingKey_Default(t *testing.T) { | ||
inOutTest(t, `{{ .name }}`, "<no value>", "--missing-key", "default") | ||
} | ||
|
||
func TestMissingKey_Zero(t *testing.T) { | ||
inOutTest(t, `{{ .name }}`, "<no value>", "--missing-key", "zero") | ||
} | ||
|
||
func TestMissingKey_Fallback(t *testing.T) { | ||
inOutTest(t, `{{ .name | default "Alex" }}`, "Alex", "--missing-key", "default") | ||
} | ||
|
||
func TestMissingKey_NotSpecified(t *testing.T) { | ||
inOutContainsError(t, `{{ .name | default "Alex" }}`, `map has no entry for key \"name\"`) | ||
} | ||
|
||
func TestMissingKey_Error(t *testing.T) { | ||
inOutContainsError(t, `{{ .name | default "Alex" }}`, `map has no entry for key \"name\"`, "--missing-key", "error") | ||
} |
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