1
0
Fork 0
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:
Jan Christoph Uhde 2018-03-06 10:59:52 +01:00
parent f1a4583f23
commit 4e609bad79

View 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))
}