(ft filetests.FileTests)
| 54 | } |
| 55 | |
| 56 | func EvalAndValidateTemplate(ft filetests.FileTests) filetests.EvaluateTemplate { |
| 57 | return func(src string) (filetests.MarshalableResult, *filetests.TestErr) { |
| 58 | result, testErr := ft.DefaultEvalTemplate(src) |
| 59 | if testErr != nil { |
| 60 | return nil, testErr |
| 61 | } |
| 62 | |
| 63 | err := validations.ProcessAssertValidateAnns(result.(yamlmeta.Node)) |
| 64 | if err != nil { |
| 65 | return nil, filetests.NewTestErr(err, fmt.Errorf("Failed to process @assert/validate annotations: %s", err)) |
| 66 | } |
| 67 | |
| 68 | chk, err := validations.Run(result.(yamlmeta.Node), "template-test") |
| 69 | if err != nil { |
| 70 | err := fmt.Errorf("\n%s", err) |
| 71 | return nil, filetests.NewTestErr(err, fmt.Errorf("Unexpected error (did you include the \"ERR:\" marker in the output?):%v", err)) |
| 72 | } |
| 73 | // TODO: proper error handling! |
| 74 | if chk.HasInvalidations() { |
| 75 | err := fmt.Errorf("\n%s", chk.ResultsAsString()) |
| 76 | return nil, filetests.NewTestErr(err, fmt.Errorf("Unexpected violations (did you include the \"ERR:\" marker in the output?):%v", err)) |
| 77 | } |
| 78 | |
| 79 | return result, testErr |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | func showTemplateCode(showTemplateCodeFlag string) bool { |
| 84 | return strings.HasPrefix(strings.ToLower(showTemplateCodeFlag), "t") |
no test coverage detected
searching dependent graphs…