-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathprovider_test.go
More file actions
38 lines (31 loc) · 840 Bytes
/
provider_test.go
File metadata and controls
38 lines (31 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package assert
import (
"reflect"
"testing"
)
type mockTestingT struct {
t *testing.T
failed bool
errors []string
}
func setupWithMockT(t *testing.T) (provider *Provider, mockT *mockTestingT) {
mockT = &mockTestingT{t: t}
provider = setupImpl(mockT, mockT)
return
}
func (mockT *mockTestingT) Log(location *location, message string) {
mockT.errors = append(mockT.errors, message)
}
func (mockT *mockTestingT) Fail() {
mockT.failed = true
}
func (mockT *mockTestingT) HasNoErrors() {
if mockT.failed || len(mockT.errors) > 0 {
mockT.t.Errorf("Expected to have no errors, but had <%s>.", mockT.errors)
}
}
func (mockT *mockTestingT) HasErrorMessages(messages ...string) {
if !mockT.failed || !reflect.DeepEqual(mockT.errors, messages) {
mockT.t.Errorf("Expected <%s>, but was <%s>.", messages, mockT.errors)
}
}