Skip to content

Commit b653b34

Browse files
committed
move test to the right package and add data source to provier
1 parent 38f1112 commit b653b34

File tree

3 files changed

+42
-4
lines changed

3 files changed

+42
-4
lines changed

internal/provider/provider.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ func Provider(config *Config) plugin.ProviderFunc {
247247
"scaleway_account_ssh_key": iam.DataSourceSSHKey(),
248248
"scaleway_availability_zones": az.DataSourceAvailabilityZones(),
249249
"scaleway_baremetal_offer": baremetal.DataSourceOffer(),
250+
"scaleway_baremetal_easy_partitioning": baremetal.DataEasyPartitioning(),
250251
"scaleway_baremetal_option": baremetal.DataSourceOption(),
251252
"scaleway_baremetal_os": baremetal.DataSourceOS(),
252253
"scaleway_baremetal_server": baremetal.DataSourceServer(),

internal/services/baremetal/easy_partitioning_data_source.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func DataEasyPartitioning() *schema.Resource {
2020
Required: true,
2121
Description: "ID of the server offer",
2222
},
23-
"os": {
23+
"os_id": {
2424
Type: schema.TypeString,
2525
Required: true,
2626
Description: "The base image of the server",
@@ -60,7 +60,7 @@ func dataEasyPartitioningRead(ctx context.Context, d *schema.ResourceData, m int
6060
return diag.FromErr(err)
6161
}
6262

63-
osID := d.Get("os").(string)
63+
osID := d.Get("os_id").(string)
6464

6565
os, err := api.GetOS(&baremetal.GetOSRequest{
6666
Zone: fallBackZone,
@@ -97,13 +97,13 @@ func dataEasyPartitioningRead(ctx context.Context, d *schema.ResourceData, m int
9797
return diag.FromErr(err)
9898
}
9999

100+
print(defaultPartitioningSchema)
100101
//TODO checker si offer custom partitoning
101102
//TODO checker si offer et os compatible
102103
//TODO get default partitioning
103104
//TODO unmarshall
104105
//TODO replacer les valeurs
105106
//TODO marshal
106107

107-
var diags diag.Diagnostics
108-
return diags
108+
return nil
109109
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package baremetal_test
2+
3+
import (
4+
"fmt"
5+
"testing"
6+
7+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
8+
"github.com/scaleway/terraform-provider-scaleway/v2/internal/acctest"
9+
)
10+
11+
const (
12+
offerISData = "a60ae97c-268c-40cb-af5f-dd276e917ed7"
13+
osID = "7d1914e1-f4ab-47fc-bd8c-b3a23143e87a"
14+
incompatibleOsIS = "4aff4d9d-b1f4-44b0-ab6f-e4711ac11711"
15+
)
16+
17+
func TestAccDataSourceEasyParitioning_Basic(t *testing.T) {
18+
tt := acctest.NewTestTools(t)
19+
defer tt.Cleanup()
20+
21+
resource.ParallelTest(t, resource.TestCase{
22+
PreCheck: func() { acctest.PreCheck(t) },
23+
ProviderFactories: tt.ProviderFactories,
24+
Steps: []resource.TestStep{
25+
{
26+
Config: fmt.Sprintf(
27+
`
28+
data "scaleway_easy_partitioning" "test" {
29+
offer_id = "%s"
30+
os_id = "%s"
31+
}
32+
`, offerISData, osID,
33+
),
34+
},
35+
},
36+
})
37+
}

0 commit comments

Comments
 (0)