-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathreset.go
More file actions
40 lines (38 loc) · 902 Bytes
/
Copy pathreset.go
File metadata and controls
40 lines (38 loc) · 902 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
39
40
package test
// Resetter is an interface that describes the Reset method. A Resetter
// is any type that can be reset to some initial state.
type Resetter interface {
Reset()
}
// Reset calls the Reset method on each Resetter in the list. A Resetter
// is any type that implements the Resetter interface:
//
// type Resetter interface {
// Reset()
// }
//
// Reset is a convenience function for resetting multiple Resetters,
// such as fakes and mocks.
//
// # Example
//
// func TestSomething(t *testing.T) {
// // ARRANGE
// fake := NewFake()
// mock := NewMock()
// defer test.Reset(fake, mock)
//
// // .. set expectations on mock
//
// // ACT
// // .. call the code under test
//
// // ASSERT
// // .. assertions additional to testing mock expectations (if any)
// test.MockExpectations(t, mock)
// }
func Reset(r ...Resetter) {
for _, resetter := range r {
resetter.Reset()
}
}