diff --git a/api/v1/qdrantcluster_types_test.go b/api/v1/qdrantcluster_types_test.go new file mode 100644 index 0000000..8abe5ba --- /dev/null +++ b/api/v1/qdrantcluster_types_test.go @@ -0,0 +1,19 @@ +package v1 + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestValidate(t *testing.T) { + r := Resources{} + err := r.Validate("test") + require.Error(t, err) + require.ErrorContains(t, err, "test.CPU error: quantities must match the regular expression '^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$'") + + spec := QdrantClusterSpec{} + err = spec.Validate() + require.Error(t, err) + require.ErrorContains(t, err, "Spec.Resources.CPU error: quantities must match the regular expression '^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$'") +} diff --git a/go.mod b/go.mod index 366e208..2fd18cd 100644 --- a/go.mod +++ b/go.mod @@ -5,12 +5,14 @@ go 1.23 require ( github.com/fluxcd/helm-controller/api v1.1.0 github.com/fluxcd/source-controller/api v1.4.1 + github.com/stretchr/testify v1.9.0 k8s.io/api v0.31.2 k8s.io/apimachinery v0.31.2 sigs.k8s.io/controller-runtime v0.19.1 ) require ( + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/fluxcd/pkg/apis/acl v0.3.0 // indirect github.com/fluxcd/pkg/apis/kustomize v1.6.1 // indirect github.com/fluxcd/pkg/apis/meta v1.6.1 // indirect @@ -21,11 +23,13 @@ require ( github.com/json-iterator/go v1.1.12 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/x448/float16 v0.8.4 // indirect golang.org/x/net v0.30.0 // indirect golang.org/x/text v0.19.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/apiextensions-apiserver v0.31.1 // indirect k8s.io/klog/v2 v2.130.1 // indirect k8s.io/utils v0.0.0-20240921022957-49e7df575cb6 // indirect