| 66 | } |
| 67 | |
| 68 | func validateExpectedOut(got string, expected ExpectedOut) matcher.MatcherResult { |
| 69 | var m matcher.Matcher |
| 70 | var result matcher.MatcherResult |
| 71 | result.Success = true |
| 72 | |
| 73 | if expected.Exactly != "" { |
| 74 | m = matcher.NewMatcher(matcher.Text) |
| 75 | if result = m.Match(got, expected.Exactly); !result.Success { |
| 76 | return result |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | m = matcher.NewMatcher(matcher.Contains) |
| 81 | for _, c := range expected.Contains { |
| 82 | if result = m.Match(got, c); !result.Success { |
| 83 | return result |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | if expected.LineCount != 0 { |
| 88 | result = validateExpectedLineCount(got, expected) |
| 89 | if !result.Success { |
| 90 | return result |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | if len(expected.Lines) > 0 { |
| 95 | result = validateExpectedLines(got, expected) |
| 96 | if !result.Success { |
| 97 | return result |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | m = matcher.NewMatcher(matcher.NotContains) |
| 102 | for _, c := range expected.NotContains { |
| 103 | if result = m.Match(got, c); !result.Success { |
| 104 | return result |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | m = matcher.NewMatcher(matcher.JSON) |
| 109 | for i, v := range expected.JSON { |
| 110 | if result = m.Match(got, map[string]string{i: v}); !result.Success { |
| 111 | return result |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | m = matcher.NewMatcher(matcher.XML) |
| 116 | for i, v := range expected.XML { |
| 117 | if result = m.Match(got, map[string]string{i: v}); !result.Success { |
| 118 | return result |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | if expected.File != "" { |
| 123 | m = matcher.NewMatcher(matcher.File) |
| 124 | if result = m.Match(got, expected.File); !result.Success { |
| 125 | return result |