(got string, expected ExpectedOut)
| 141 | } |
| 142 | |
| 143 | func validateExpectedLines(got string, expected ExpectedOut) matcher.MatcherResult { |
| 144 | m := matcher.NewMatcher(matcher.Equal) |
| 145 | actualLines := strings.Split(got, getLineBreak()) |
| 146 | result := matcher.MatcherResult{Success: true} |
| 147 | |
| 148 | for key, expectedLine := range expected.Lines { |
| 149 | // line number 0 or below 0 |
| 150 | if key <= 0 { |
| 151 | panic(fmt.Sprintf("Invalid line number given %d", key)) |
| 152 | } |
| 153 | |
| 154 | // line number exceeds result set |
| 155 | if key > len(actualLines) { |
| 156 | return matcher.MatcherResult{ |
| 157 | Success: false, |
| 158 | Diff: fmt.Sprintf( |
| 159 | "Line number %d does not exists in result: \n\n%s", |
| 160 | key, |
| 161 | strings.Join(actualLines, "\n"), |
| 162 | ), |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | if result = m.Match(actualLines[key-1], expectedLine); !result.Success { |
| 167 | return result |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | return result |
| 172 | } |
| 173 | |
| 174 | func getLineBreak() string { |
| 175 | return "\n" |
no test coverage detected