@@ -2,6 +2,7 @@ package account_test
22
33import (
44 "fmt"
5+ "strconv"
56 "testing"
67
78 "github.com/hashicorp/terraform-plugin-testing/helper/resource"
@@ -125,6 +126,11 @@ func TestAccDataSourceProject_List(t *testing.T) {
125126 orgID = dummyOrgID
126127 }
127128
129+ projectID , projectIDExists := tt .Meta .ScwClient ().GetDefaultProjectID ()
130+ if ! projectIDExists {
131+ t .Skip ("no default project ID" )
132+ }
133+
128134 resource .ParallelTest (t , resource.TestCase {
129135 ProtoV6ProviderFactories : tt .ProviderFactories ,
130136 CheckDestroy : resource .ComposeTestCheckFunc (
@@ -137,11 +143,21 @@ func TestAccDataSourceProject_List(t *testing.T) {
137143 organization_id = "%s"
138144 }` , orgID ),
139145 Check : resource .ComposeTestCheckFunc (
140- resource .TestCheckResourceAttr ("data.scaleway_account_projects.projects" , "projects.#" , "8" ),
141- resource .TestCheckResourceAttr ("data.scaleway_account_projects.projects" , "projects.0.id" , "6867048b-fe12-4e96-835e-41c79a39604b" ),
142- resource .TestCheckResourceAttr ("data.scaleway_account_projects.projects" , "projects.1.id" , "8cc8dd4d-a094-407a-89a3-9d004674e936" ),
146+ resource .TestCheckResourceAttrSet ("data.scaleway_account_projects.projects" , "projects.#" ),
147+ resource .TestCheckResourceAttrWith ("data.scaleway_account_projects.projects" , "projects.#" , func (value string ) error {
148+ count , err := strconv .Atoi (value )
149+ if err != nil {
150+ return err
151+ }
152+
153+ if count < 1 {
154+ return fmt .Errorf ("expected at least one project, got %d" , count )
155+ }
156+
157+ return nil
158+ }),
159+ resource .TestCheckResourceAttr ("data.scaleway_account_projects.projects" , "projects.0.id" , projectID ),
143160 resource .TestCheckResourceAttr ("data.scaleway_account_projects.projects" , "projects.0.name" , "default" ),
144- resource .TestCheckResourceAttr ("data.scaleway_account_projects.projects" , "projects.1.name" , "tf_tests_container_trigger_sqs" ),
145161 ),
146162 },
147163 },
0 commit comments