Skip to content

Commit

Permalink
fixing unit test errors
Browse files Browse the repository at this point in the history
Signed-off-by: lakshmimsft <ljavadekar@microsoft.com>
  • Loading branch information
lakshmimsft committed Feb 5, 2025
1 parent 0d8d09b commit 2e7dd87
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/corerp/backend/deployment/deploymentprocessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (dp *deploymentProcessor) Render(ctx context.Context, resourceID resources.

c := app.Properties.Status.Compute
// Override environment-scope namespace with application-scope kubernetes namespace.
if c.Kind == rpv1.KubernetesComputeKind {
if c != nil && c.Kind == rpv1.KubernetesComputeKind {
envOptions.Namespace = c.KubernetesCompute.Namespace
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ func (t *TestResource) GetRecipe() *portableresources.ResourceRecipe {
return &t.Properties.Recipe
}

// SetRecipe allows updating the recipe in the resource.
func (t *TestResource) SetRecipe(r *portableresources.ResourceRecipe) {
t.Properties.Recipe = *r
}

type TestResourceProperties struct {
rpv1.BasicResourceProperties
IsProcessed bool `json:"isProcessed"`
Expand Down Expand Up @@ -207,6 +212,7 @@ func TestCreateOrUpdateResource_Run(t *testing.T) {
nil,
fmt.Errorf("could not find recipe %q in environment %q", "test-recipe", TestEnvironmentID),
},

{
"runtime-configuration-err",
func(recipeCfg *controllerconfig.RecipeControllerConfig, options ctrl.Options) (ctrl.Controller, error) {
Expand Down
7 changes: 7 additions & 0 deletions pkg/portableresources/processors/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ func NewValidator(connectionValues *map[string]any, connectionSecrets *map[strin
*connectionSecrets = map[string]rpv1.SecretValueReference{}
*outputResources = []rpv1.OutputResource{}

if status == nil {
status = new(rpv1.RecipeStatus)
}

return &Validator{
ConnectionValues: *connectionValues,
ConnectionSecrets: *connectionSecrets,
Expand Down Expand Up @@ -166,6 +170,9 @@ func (v *Validator) SetAndValidate(output *recipes.RecipeOutput) error {
*v.OutputResources = append(*v.OutputResources, recipeResources...)

if output.Status != nil {
if v.Status == nil {
v.Status = new(rpv1.RecipeStatus)
}
*v.Status = *output.Status
}
}
Expand Down

0 comments on commit 2e7dd87

Please sign in to comment.