in functional_tests/src/runtest/asserts.go [25:52]
func DoStringAssert(value string, rule StringAssert) string {
if len(rule.Exactly) > 0 {
if value != rule.Exactly {
return fmt.Sprintf("Should have matched exactly:\n%s\n... but was:\n%s", rule.Exactly, value)
}
}
if len(rule.Equals) > 0 {
trimmed := strings.TrimSpace(value)
if trimmed != rule.Equals {
return fmt.Sprintf("Should have been:\n%s\n... but was:\n%s", rule.Equals, trimmed)
}
}
if len(rule.Matches) > 0 {
r, err := regexp.Compile(rule.Matches)
if err != nil {
return fmt.Sprintf("Regex failed to compile: %s", rule.Matches)
}
if !r.MatchString(value) {
return fmt.Sprintf("Should have matched regex:\n%s\n... but was:\n%s", rule.Matches, value)
}
}
if rule.MustBeEmpty {
if len(value) > 0 {
return fmt.Sprintf("Should have been empty, but was:\n%s", value)
}
}
return ""
}