mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
add some tests for util/k8sutil/erros.go
This commit is contained in:
parent
f1a4583f23
commit
4e609bad79
1 changed files with 34 additions and 0 deletions
34
pkg/util/k8sutil/errors_test.go
Normal file
34
pkg/util/k8sutil/errors_test.go
Normal file
|
@ -0,0 +1,34 @@
|
|||
package k8sutil
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||
)
|
||||
|
||||
var (
|
||||
conflictError = apierrors.NewConflict(schema.GroupResource{"groupName", "resourceName"}, "something", os.ErrInvalid)
|
||||
existsError = apierrors.NewAlreadyExists(schema.GroupResource{"groupName", "resourceName"}, "something")
|
||||
invalidError = apierrors.NewInvalid(schema.GroupKind{"groupName", "kindName"}, "something", field.ErrorList{})
|
||||
notFoundError = apierrors.NewNotFound(schema.GroupResource{"groupName", "resourceName"}, "something")
|
||||
)
|
||||
|
||||
func TestIsAlreadyExists(t *testing.T) {
|
||||
assert.False(t, IsAlreadyExists(conflictError))
|
||||
assert.True(t, IsAlreadyExists(existsError))
|
||||
}
|
||||
|
||||
func TestIsConflict(t *testing.T) {
|
||||
assert.False(t, IsConflict(existsError))
|
||||
assert.True(t, IsConflict(conflictError))
|
||||
}
|
||||
|
||||
func TestIsNotFound(t *testing.T) {
|
||||
assert.False(t, IsNotFound(invalidError))
|
||||
assert.True(t, IsNotFound(notFoundError))
|
||||
}
|
Loading…
Reference in a new issue