Skip to content

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
Signed-off-by: Brad Wadsworth <[email protected]>
  • Loading branch information
Brad Wadsworth committed May 14, 2024
1 parent d46db2c commit a85ee39
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ require (
go.uber.org/zap v1.26.0
golang.org/x/oauth2 v0.16.0
gopkg.in/alecthomas/kingpin.v2 v2.2.6
gotest.tools v2.2.0+incompatible
k8s.io/api v0.29.1
k8s.io/apimachinery v0.29.1
k8s.io/client-go v0.29.1
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,6 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
k8s.io/api v0.29.1 h1:DAjwWX/9YT7NQD4INu49ROJuZAAAP/Ijki48GUPzxqw=
k8s.io/api v0.29.1/go.mod h1:7Kl10vBRUXhnQQI8YR/R327zXC8eJ7887/+Ybta+RoQ=
k8s.io/apiextensions-apiserver v0.29.1 h1:S9xOtyk9M3Sk1tIpQMu9wXHm5O2MX6Y1kIpPMimZBZw=
Expand Down
36 changes: 22 additions & 14 deletions internal/controller/object/object_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -816,9 +816,9 @@ func Test_helmExternal_Update(t *testing.T) {
args: args{
mg: kubernetesObject(),
client: resource.ClientApplicator{
Applicator: resource.ApplyFn(func(context.Context, client.Object, ...resource.ApplyOption) error {
return errBoom
}),
Client: &test.MockClient{
MockUpdate: test.NewMockUpdateFn(errBoom),
},
},
},
want: want{
Expand All @@ -829,16 +829,18 @@ func Test_helmExternal_Update(t *testing.T) {
args: args{
mg: kubernetesObject(func(obj *v1alpha2.Object) {
obj.Spec.ForProvider.Manifest.Raw = []byte(`{
"apiVersion": "v1",
"kind": "Namespace" }`)
"apiVersion": "v1",
"kind": "Namespace" }`)
}),
client: resource.ClientApplicator{
Applicator: resource.ApplyFn(func(ctx context.Context, obj client.Object, op ...resource.ApplyOption) error {
if obj.GetName() != testObjectName {
t.Errorf("Name should default to object name when not provider in manifest")
}
return nil
}),
Client: &test.MockClient{
MockUpdate: test.NewMockUpdateFn(nil, func(obj client.Object) error {
if obj.GetName() != testObjectName {
t.Errorf("Name should default to object name when not provider in manifest")
}
return nil
}),
},
},
},
want: want{
Expand All @@ -849,9 +851,15 @@ func Test_helmExternal_Update(t *testing.T) {
args: args{
mg: kubernetesObject(),
client: resource.ClientApplicator{
Applicator: resource.ApplyFn(func(context.Context, client.Object, ...resource.ApplyOption) error {
return nil
}),
Client: &test.MockClient{
MockUpdate: test.NewMockUpdateFn(nil, func(obj client.Object) error {
_, ok := obj.GetAnnotations()[corev1.LastAppliedConfigAnnotation]
if !ok {
t.Errorf("Last applied annotation not set with create")
}
return nil
}),
},
},
},
want: want{
Expand Down

0 comments on commit a85ee39

Please sign in to comment.