util/sprig/flow_control_test.go
raw| 1 | package sprig |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "testing" |
| 6 | |
| 7 | "github.com/stretchr/testify/assert" |
| 8 | ) |
| 9 | |
| 10 | func TestFail(t *testing.T) { |
| 11 | const msg = "This is an error!" |
| 12 | tpl := fmt.Sprintf(`{{fail "%s"}}`, msg) |
| 13 | _, err := runRaw(tpl, nil) |
| 14 | assert.Error(t, err) |
| 15 | assert.Contains(t, err.Error(), msg) |
| 16 | } |