mirror of https://github.com/k3s-io/k3s
Merge pull request #74735 from liggitt/simplfy-package-test
Simplify package skipping testpull/564/head
commit
ae561229a6
|
@ -16,7 +16,10 @@ limitations under the License.
|
|||
|
||||
package naming
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGetNameFromCallsite(t *testing.T) {
|
||||
tests := []struct {
|
||||
|
@ -26,17 +29,17 @@ func TestGetNameFromCallsite(t *testing.T) {
|
|||
}{
|
||||
{
|
||||
name: "simple",
|
||||
expected: "k8s.io/apimachinery/pkg/util/naming/from_stack_test.go:50",
|
||||
expected: "k8s.io/apimachinery/pkg/util/naming/from_stack_test.go:",
|
||||
},
|
||||
{
|
||||
name: "ignore-package",
|
||||
ignoredPackages: []string{"k8s.io/apimachinery/pkg/util/naming"},
|
||||
expected: "testing/testing.go:827",
|
||||
expected: "testing/testing.go:",
|
||||
},
|
||||
{
|
||||
name: "ignore-file",
|
||||
ignoredPackages: []string{"k8s.io/apimachinery/pkg/util/naming/from_stack_test.go"},
|
||||
expected: "testing/testing.go:827",
|
||||
expected: "testing/testing.go:",
|
||||
},
|
||||
{
|
||||
name: "ignore-multiple",
|
||||
|
@ -48,8 +51,8 @@ func TestGetNameFromCallsite(t *testing.T) {
|
|||
for _, tc := range tests {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
actual := GetNameFromCallsite(tc.ignoredPackages...)
|
||||
if tc.expected != actual {
|
||||
t.Fatalf("expected %q, got %q", tc.expected, actual)
|
||||
if !strings.HasPrefix(actual, tc.expected) {
|
||||
t.Fatalf("expected string with prefix %q, got %q", tc.expected, actual)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue