| 58 | } |
| 59 | |
| 60 | func (r *Registry) Verify(t Testing) { |
| 61 | var unmatchedStubStacks []string |
| 62 | for _, s := range r.stubs { |
| 63 | if !s.matched && !s.exclude { |
| 64 | unmatchedStubStacks = append(unmatchedStubStacks, s.Stack) |
| 65 | } |
| 66 | } |
| 67 | if len(unmatchedStubStacks) > 0 { |
| 68 | t.Helper() |
| 69 | stacks := strings.Builder{} |
| 70 | for i, stack := range unmatchedStubStacks { |
| 71 | stacks.WriteString(fmt.Sprintf("Stub %d:\n", i+1)) |
| 72 | stacks.WriteString(fmt.Sprintf("\t%s", stack)) |
| 73 | if stack != unmatchedStubStacks[len(unmatchedStubStacks)-1] { |
| 74 | stacks.WriteString("\n") |
| 75 | } |
| 76 | } |
| 77 | // about dead stubs and what they were trying to match |
| 78 | t.Errorf("%d HTTP stubs unmatched, stacks:\n%s", len(unmatchedStubStacks), stacks.String()) |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | // RoundTrip satisfies http.RoundTripper |
| 83 | func (r *Registry) RoundTrip(req *http.Request) (*http.Response, error) { |