Skip to content

Commit

Permalink
Added a small test to check Validate (missing the resources) (#44)
Browse files Browse the repository at this point in the history
We could improve the test later to test more senarios
  • Loading branch information
Robert-Stam authored Nov 20, 2024
1 parent a38c821 commit 706498a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
19 changes: 19 additions & 0 deletions api/v1/qdrantcluster_types_test.go
Original file line number Diff line number Diff line change
@@ -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]*)$'")
}
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 706498a

Please sign in to comment.