Skip to content

Commit 6849163

Browse files
committed
testing
1 parent 20e80ec commit 6849163

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

internal/services/inference/model_data_source.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
func DataSourceModel() *schema.Resource {
1616
dsSchema := datasource.SchemaFromResourceSchema(ResourceModel().Schema)
1717

18-
//datasource.FixDatasourceSchemaFlags(dsSchema, true, "name")
1918
datasource.AddOptionalFieldsToSchema(dsSchema, "url", "name")
2019
dsSchema["name"].ConflictsWith = []string{"model_id"}
2120
dsSchema["model_id"] = &schema.Schema{
@@ -39,12 +38,13 @@ func DataSourceModelRead(ctx context.Context, d *schema.ResourceData, m interfac
3938
}
4039

4140
modelID, ok := d.GetOk("model_id")
41+
pageSize := uint32(1000)
4242
if !ok {
4343
modelName := d.Get("name").(string)
4444
modelList, err := api.ListModels(&inference.ListModelsRequest{
4545
Region: region,
46-
Name: scw.StringPtr(modelName),
4746
ProjectID: types.ExpandStringPtr(d.Get("project_id")),
47+
PageSize: &pageSize,
4848
}, scw.WithContext(ctx))
4949
if err != nil {
5050
return diag.FromErr(err)
Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,32 @@
1-
package inference
1+
package inference_test
2+
3+
import (
4+
"fmt"
5+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
6+
"github.com/scaleway/terraform-provider-scaleway/v2/internal/acctest"
7+
"testing"
8+
)
9+
10+
func TestAccDataSourceModel_Basic(t *testing.T) {
11+
tt := acctest.NewTestTools(t)
12+
defer tt.Cleanup()
13+
14+
modelName := "mistral/pixtral-12b-2409:bf16"
15+
resource.ParallelTest(t, resource.TestCase{
16+
PreCheck: func() { acctest.PreCheck(t) },
17+
ProviderFactories: tt.ProviderFactories,
18+
Steps: []resource.TestStep{
19+
{
20+
Config: fmt.Sprintf(`
21+
data "scaleway_inference_model" "my-model" {
22+
name = "%s"
23+
}
24+
25+
`, modelName),
26+
Check: resource.ComposeTestCheckFunc(
27+
resource.TestCheckResourceAttr("data.scaleway_inference_model.my-model", "name", modelName),
28+
),
29+
},
30+
},
31+
})
32+
}

0 commit comments

Comments
 (0)