diff --git a/controllers/weightsandbiases_controller_test.go b/controllers/weightsandbiases_controller_test.go index ee990eb..e2a8419 100644 --- a/controllers/weightsandbiases_controller_test.go +++ b/controllers/weightsandbiases_controller_test.go @@ -10,6 +10,8 @@ import ( "github.com/wandb/operator/pkg/wandb/spec" "github.com/wandb/operator/pkg/wandb/spec/channel/deployer/deployerfakes" "github.com/wandb/operator/pkg/wandb/spec/charts" + "github.com/wandb/operator/pkg/wandb/spec/state" + "github.com/wandb/operator/pkg/wandb/spec/state/secrets" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" @@ -163,12 +165,21 @@ var _ = Describe("WeightsandbiasesController", func() { "global": map[string]interface{}{ "host": "https://qa-google.wandb.io", }, - "_releaseId": "0b901113-8135-48ae-bdaf-6fa82b4b2d28", }}, }, } err := k8sClient.Create(ctx, &wandb) Expect(err).ToNot(HaveOccurred()) + + // Create UserSpec with _releaseId + userSpec := &spec.Spec{ + Values: map[string]interface{}{ + "_releaseId": "0b901113-8135-48ae-bdaf-6fa82b4b2d28", + }, + } + err = state.New(ctx, k8sClient, &wandb, scheme.Scheme, secrets.New(ctx, k8sClient, &wandb, scheme.Scheme)).SetUserInput(userSpec) + Expect(err).ToNot(HaveOccurred()) + res, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: types.NamespacedName{Name: wandb.Name, Namespace: wandb.Namespace}}) Expect(err).ToNot(HaveOccurred()) Expect(res).To(Equal(ctrl.Result{RequeueAfter: time.Duration(1 * time.Hour)})) @@ -189,12 +200,16 @@ var _ = Describe("WeightsandbiasesController", func() { Expect(err).To(HaveOccurred()) }) - It("Should use the specified _releaseId", func() { + It("Should use the specified _releaseId from UserSpec in the final spec", func() { ctx := context.Background() wandb := wandbcomv1.WeightsAndBiases{} err := k8sClient.Get(ctx, types.NamespacedName{Name: "test-release-id", Namespace: "default"}, &wandb) Expect(err).ToNot(HaveOccurred()) - Expect(wandb.Spec.Values.Object["_releaseId"]).To(Equal("0b901113-8135-48ae-bdaf-6fa82b4b2d28")) + + specManager := state.New(ctx, k8sClient, &wandb, scheme.Scheme, secrets.New(ctx, k8sClient, &wandb, scheme.Scheme)) + activeSpec, err := specManager.GetActive() + Expect(err).ToNot(HaveOccurred()) + Expect(activeSpec.Values["_releaseId"]).To(Equal("0b901113-8135-48ae-bdaf-6fa82b4b2d28")) }) }) Describe("Reconcile and Apply", func() {