@@ -16,7 +16,10 @@ limitations under the License.
16
16
17
17
package naming
18
18
19
- import "testing"
19
+ import (
20
+ "strings"
21
+ "testing"
22
+ )
20
23
21
24
func TestGetNameFromCallsite (t * testing.T ) {
22
25
tests := []struct {
@@ -26,17 +29,17 @@ func TestGetNameFromCallsite(t *testing.T) {
26
29
}{
27
30
{
28
31
name : "simple" ,
29
- expected : "k8s.io/apimachinery/pkg/util/naming/from_stack_test.go:50 " ,
32
+ expected : "k8s.io/apimachinery/pkg/util/naming/from_stack_test.go:" ,
30
33
},
31
34
{
32
35
name : "ignore-package" ,
33
36
ignoredPackages : []string {"k8s.io/apimachinery/pkg/util/naming" },
34
- expected : "testing/testing.go:827 " ,
37
+ expected : "testing/testing.go:" ,
35
38
},
36
39
{
37
40
name : "ignore-file" ,
38
41
ignoredPackages : []string {"k8s.io/apimachinery/pkg/util/naming/from_stack_test.go" },
39
- expected : "testing/testing.go:827 " ,
42
+ expected : "testing/testing.go:" ,
40
43
},
41
44
{
42
45
name : "ignore-multiple" ,
@@ -48,8 +51,8 @@ func TestGetNameFromCallsite(t *testing.T) {
48
51
for _ , tc := range tests {
49
52
t .Run (tc .name , func (t * testing.T ) {
50
53
actual := GetNameFromCallsite (tc .ignoredPackages ... )
51
- if tc .expected != actual {
52
- t .Fatalf ("expected %q, got %q" , tc .expected , actual )
54
+ if ! strings . HasPrefix ( actual , tc .expected ) {
55
+ t .Fatalf ("expected string with prefix %q, got %q" , tc .expected , actual )
53
56
}
54
57
})
55
58
}
0 commit comments