Skip to content

Commit

Permalink
fix(mongodb): plan is nil
Browse files Browse the repository at this point in the history
Closes #82
  • Loading branch information
LeCrabe committed Jul 12, 2024
1 parent b80a5ed commit 321ff50
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/resources/mongodb/crud.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (r *ResourceMongoDB) Create(ctx context.Context, req resource.CreateRequest
addonsProviders := addonsProvidersRes.Payload()
prov := pkg.LookupAddonProvider(*addonsProviders, "mongodb-addon")
plan := pkg.LookupProviderPlan(prov, mg.Plan.ValueString())
if plan.ID == "" {
if plan == nil || plan.ID == "" {
resp.Diagnostics.AddError("failed to find plan", "expect: "+strings.Join(pkg.ProviderPlansAsList(prov), ", ")+", got: "+mg.Plan.String())
return
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/resources/mongodb/mongodb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestAccMongoDB_basic(t *testing.T) {
cc := client.New(client.WithAutoOauthConfig())
org := os.Getenv("ORGANISATION")
providerBlock := helper.NewProvider("clevercloud").SetOrganisation(org).String()
mongodbBlock := helper.NewRessource("clevercloud_mongodb", rName, helper.SetKeyValues(map[string]any{"name": rName, "plan": "dev", "region": "par"})).String()
mongodbBlock := helper.NewRessource("clevercloud_mongodb", rName, helper.SetKeyValues(map[string]any{"name": rName, "plan": "xs_med", "region": "par"})).String()

resource.Test(t, resource.TestCase{
PreCheck: func() {
Expand Down Expand Up @@ -71,7 +71,7 @@ func TestAccMongoDB_RefreshDeleted(t *testing.T) {
cc := client.New(client.WithAutoOauthConfig())
org := os.Getenv("ORGANISATION")
providerBlock := helper.NewProvider("clevercloud").SetOrganisation(org).String()
mongodbBlock2 := helper.NewRessource("clevercloud_mongodb", rName, helper.SetKeyValues(map[string]any{"name": rName, "plan": "dev", "region": "par"})).String()
mongodbBlock2 := helper.NewRessource("clevercloud_mongodb", rName, helper.SetKeyValues(map[string]any{"name": rName, "plan": "xs_med", "region": "par"})).String()

resource.Test(t, resource.TestCase{
PreCheck: func() {
Expand Down

0 comments on commit 321ff50

Please sign in to comment.