mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-04 15:05:20 +00:00
Move field errors to pkg/util/fielderrors
Allows pkg/api to take a reference to labels.Selector and fields.Selector
This commit is contained in:
@@ -24,6 +24,7 @@ import (
|
||||
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/fielderrors"
|
||||
)
|
||||
|
||||
func TestErrorNew(t *testing.T) {
|
||||
@@ -78,11 +79,11 @@ func TestErrorNew(t *testing.T) {
|
||||
|
||||
func TestNewInvalid(t *testing.T) {
|
||||
testCases := []struct {
|
||||
Err *ValidationError
|
||||
Err *fielderrors.ValidationError
|
||||
Details *api.StatusDetails
|
||||
}{
|
||||
{
|
||||
NewFieldDuplicate("field[0].name", "bar"),
|
||||
fielderrors.NewFieldDuplicate("field[0].name", "bar"),
|
||||
&api.StatusDetails{
|
||||
Kind: "kind",
|
||||
ID: "name",
|
||||
@@ -93,7 +94,7 @@ func TestNewInvalid(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
NewFieldInvalid("field[0].name", "bar", "detail"),
|
||||
fielderrors.NewFieldInvalid("field[0].name", "bar", "detail"),
|
||||
&api.StatusDetails{
|
||||
Kind: "kind",
|
||||
ID: "name",
|
||||
@@ -104,7 +105,7 @@ func TestNewInvalid(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
NewFieldNotFound("field[0].name", "bar"),
|
||||
fielderrors.NewFieldNotFound("field[0].name", "bar"),
|
||||
&api.StatusDetails{
|
||||
Kind: "kind",
|
||||
ID: "name",
|
||||
@@ -115,7 +116,7 @@ func TestNewInvalid(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
NewFieldNotSupported("field[0].name", "bar"),
|
||||
fielderrors.NewFieldNotSupported("field[0].name", "bar"),
|
||||
&api.StatusDetails{
|
||||
Kind: "kind",
|
||||
ID: "name",
|
||||
@@ -126,7 +127,7 @@ func TestNewInvalid(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
NewFieldRequired("field[0].name"),
|
||||
fielderrors.NewFieldRequired("field[0].name"),
|
||||
&api.StatusDetails{
|
||||
Kind: "kind",
|
||||
ID: "name",
|
||||
@@ -140,7 +141,7 @@ func TestNewInvalid(t *testing.T) {
|
||||
for i, testCase := range testCases {
|
||||
vErr, expected := testCase.Err, testCase.Details
|
||||
expected.Causes[0].Message = vErr.Error()
|
||||
err := NewInvalid("kind", "name", ValidationErrorList{vErr})
|
||||
err := NewInvalid("kind", "name", fielderrors.ValidationErrorList{vErr})
|
||||
status := err.(*StatusError).ErrStatus
|
||||
if status.Code != 422 || status.Reason != api.StatusReasonInvalid {
|
||||
t.Errorf("%d: unexpected status: %#v", i, status)
|
||||
|
||||
Reference in New Issue
Block a user