-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy patherrors_test.go
80 lines (55 loc) · 2.64 KB
/
errors_test.go
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Copyright 2019 Bloomberg Finance L.P.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build testgroup_errors
// +build testgroup_errors
package testgroup_test
import (
"testing"
"github.com/bloomberg/go-testgroup"
)
// These tests are run in their own processes by Test_Errors in testgroup_test.go.
// All tests should have the prefix "Test_Error_" to be found by Test_Errors.
//------------------------------------------------------------------------------
func Test_Error_ReservedMethodWithBadArg(t *testing.T) {
testgroup.RunSerially(t, &ReservedMethodWithBadArgGroup{})
}
type ReservedMethodWithBadArgGroup struct{}
// This is a bad PreTest method since it doesn't accept *testgroup.T.
func (*ReservedMethodWithBadArgGroup) PreTest(t *testing.T) {}
//------------------------------------------------------------------------------
func Test_Error_TestMethodWithBadArg(t *testing.T) {
testgroup.RunSerially(t, &TestMethodWithBadArgGroup{})
}
type TestMethodWithBadArgGroup struct{}
func (*TestMethodWithBadArgGroup) This_method_accepts_the_wrong_type_of_T(t *testing.T) {}
//------------------------------------------------------------------------------
func Test_Error_TestMethodWithoutArg(t *testing.T) {
testgroup.RunSerially(t, &TestMethodWithoutArgGroup{})
}
type TestMethodWithoutArgGroup struct{}
func (*TestMethodWithoutArgGroup) This_method_is_missing_its_argument() {}
//------------------------------------------------------------------------------
func Test_Error_NoTestMethodsFound(t *testing.T) {
testgroup.RunSerially(t, &GroupWithoutTestMethods{})
}
type GroupWithoutTestMethods struct{}
//------------------------------------------------------------------------------
func Test_Error_MixedReceiverMethods(t *testing.T) {
// If a pointer-to-struct were passed as the argument, this would not fail.
testgroup.RunSerially(t, GroupWithMixedReceiverMethods{})
}
type GroupWithMixedReceiverMethods struct{}
// Since it has a pointer type receiver, this method is not part of the struct's method set.
func (*GroupWithMixedReceiverMethods) PointerMethod(t *testgroup.T) {}
func (GroupWithMixedReceiverMethods) NonPointerMethod(t *testgroup.T) {}