Files
Oscar Hermoso 11e0302e71 🛒 Create data sources for images, regions and sizes (#68)
* 📚 add descriptions to resources

* 📷 Create `images` data source, plus codegen for `sizes`, `regions`

* 🍩 Create offerings example

* 🧣 Create `regions` and `sizes` data sources
2025-02-28 17:21:18 +08:00

39 lines
928 B
Go

package provider
import (
"fmt"
"strconv"
"testing"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
func TestImagesDataSource(t *testing.T) {
resource.ParallelTest(t, resource.TestCase{
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
// Create and Read testing
{
Config: providerConfig + `
data "binarylane_images" "test" {
}
`,
Check: resource.ComposeAggregateTestCheckFunc(
// Verify data source values
resource.TestCheckResourceAttrWith("data.binarylane_images.test", "images.#", func(value string) error {
count, err := strconv.Atoi(value)
if err != nil {
return err
}
if count < 1 {
return fmt.Errorf("expected at least one image, got: %d", count)
}
return nil
}),
resource.TestCheckResourceAttrSet("data.binarylane_images.test", "images.0.id"),
),
},
},
})
}