mirror of
https://github.com/opentffoundation/opentf.git
synced 2026-03-13 01:00:50 -04:00
* provider/scaleway: fix bootscript tests the bootscript tests where failing because the referenced bootscript is no longer available. for now this just makes the tests pass again, next step should be to lookup a bootscript so we don't have to update the tests all the time * provider/scaleway: fix bootscript data source filter bug when providing a name only the architecture was ignoerd, which can lead to issues since some bootscript names are identical, even though the architecture is different. * provider/scaleway: remove data bootscript exact name test the test fails after some time because scaleway removes older bootscripts. let's just settle with filtered tests for now, which don't have this problem.
55 lines
1.3 KiB
Go
55 lines
1.3 KiB
Go
package scaleway
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/hashicorp/terraform/helper/resource"
|
|
"github.com/hashicorp/terraform/terraform"
|
|
)
|
|
|
|
func TestAccScalewayDataSourceBootscript_Filtered(t *testing.T) {
|
|
resource.Test(t, resource.TestCase{
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
Providers: testAccProviders,
|
|
Steps: []resource.TestStep{
|
|
resource.TestStep{
|
|
Config: testAccCheckScalewayBootscriptFilterConfig,
|
|
Check: resource.ComposeTestCheckFunc(
|
|
testAccCheckBootscriptID("data.scaleway_bootscript.debug"),
|
|
resource.TestCheckResourceAttr("data.scaleway_bootscript.debug", "architecture", "arm"),
|
|
resource.TestCheckResourceAttr("data.scaleway_bootscript.debug", "public", "true"),
|
|
),
|
|
},
|
|
},
|
|
})
|
|
}
|
|
|
|
func testAccCheckBootscriptID(n string) resource.TestCheckFunc {
|
|
return func(s *terraform.State) error {
|
|
rs, ok := s.RootModule().Resources[n]
|
|
if !ok {
|
|
return fmt.Errorf("Can't find bootscript data source: %s", n)
|
|
}
|
|
|
|
if rs.Primary.ID == "" {
|
|
return fmt.Errorf("bootscript data source ID not set")
|
|
}
|
|
|
|
scaleway := testAccProvider.Meta().(*Client).scaleway
|
|
_, err := scaleway.GetBootscript(rs.Primary.ID)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
}
|
|
|
|
const testAccCheckScalewayBootscriptFilterConfig = `
|
|
data "scaleway_bootscript" "debug" {
|
|
architecture = "arm"
|
|
name_filter = "Rescue"
|
|
}
|
|
`
|