forked from Masterminds/sprig
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kent Rancourt
authored and
Kent Rancourt
committed
May 16, 2017
1 parent
f5b0ed4
commit 3ca3f10
Showing
4 changed files
with
32 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Flow Control Functions | ||
|
||
## fail | ||
|
||
Unconditionally returns an empty `string` and an `error` with the specified | ||
text. This is useful in scenarios where other conditionals have determined that | ||
template rendering should fail. | ||
|
||
``` | ||
fail "Please accept the end user license agreement" | ||
``` |
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,16 @@ | ||
package sprig | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestFail(t *testing.T) { | ||
const msg = "This is an error!" | ||
tpl := fmt.Sprintf(`{{fail "%s"}}`, msg) | ||
_, err := runRaw(tpl, nil) | ||
assert.Error(t, err) | ||
assert.Contains(t, err.Error(), msg) | ||
} |
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