Add a test for when a validation function is passed.
Signed-off-by: Matt Moyer <moyerm@vmware.com>
This commit is contained in:
parent
924eb1abaa
commit
6fe7a4c9dc
@ -8,6 +8,7 @@ package loginrequest
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -235,6 +236,21 @@ func TestCreateFailsWhenTokenValueIsEmptyInRequest(t *testing.T) {
|
|||||||
`.placeholder.suzerain-io.github.io "request name" is invalid: spec.token.value: Required value: token must be supplied`)
|
`.placeholder.suzerain-io.github.io "request name" is invalid: spec.token.value: Required value: token must be supplied`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCreateFailsWhenValidationFails(t *testing.T) {
|
||||||
|
storage := NewREST(&FakeToken{})
|
||||||
|
response, err := storage.Create(
|
||||||
|
context.Background(),
|
||||||
|
validLoginRequest(),
|
||||||
|
func(ctx context.Context, obj runtime.Object) error {
|
||||||
|
return fmt.Errorf("some validation error")
|
||||||
|
},
|
||||||
|
&metav1.CreateOptions{
|
||||||
|
DryRun: []string{},
|
||||||
|
})
|
||||||
|
require.Nil(t, response)
|
||||||
|
require.EqualError(t, err, "some validation error")
|
||||||
|
}
|
||||||
|
|
||||||
func TestCreateFailsWhenRequestOptionsDryRunIsNotEmpty(t *testing.T) {
|
func TestCreateFailsWhenRequestOptionsDryRunIsNotEmpty(t *testing.T) {
|
||||||
response, err := NewREST(&FakeToken{}).Create(
|
response, err := NewREST(&FakeToken{}).Create(
|
||||||
genericapirequest.NewContext(),
|
genericapirequest.NewContext(),
|
||||||
|
Loading…
Reference in New Issue
Block a user