Verify confirms that there is no semantic difference between the source cft.Template and the string representation in output. This can be used to ensure that the parse package hasn't done anything unexpected to your template.
(source *cft.Template, output string)
| 78 | // This can be used to ensure that the parse package hasn't done |
| 79 | // anything unexpected to your template. |
| 80 | func Verify(source *cft.Template, output string) error { |
| 81 | // Check it matches the original |
| 82 | validate, err := String(output) |
| 83 | if err != nil { |
| 84 | return err |
| 85 | } |
| 86 | |
| 87 | d := diff.New(source, validate) |
| 88 | if d.Mode() != diff.Unchanged { |
| 89 | return fmt.Errorf("semantic difference after formatting:\n%s", d.Format(false)) |
| 90 | } |
| 91 | |
| 92 | return nil |
| 93 | } |