Skip to content

Commit

Permalink
test: Add source_file as new argument
Browse files Browse the repository at this point in the history
Signed-off-by: SpiffyEight77 <[email protected]>
  • Loading branch information
SpiffyEight77 committed Nov 19, 2024
1 parent df060a2 commit 2bb7dc8
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions internal/storage/resource_storage_volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,38 @@ func TestAccStorageVolume_sourceVolume(t *testing.T) {
})
}

func TestAccStorageVolume_sourceFile(t *testing.T) {
t.Skip("Skipping source file test as it requires a valid backup/ISO file")

poolName := petname.Generate(2, "-")
volumeName := petname.Generate(2, "-")

resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
ProtoV6ProviderFactories: acctest.ProtoV6ProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccStorageVolume_sourceFile(poolName, volumeName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("incus_storage_pool.pool1", "name", poolName),
resource.TestCheckResourceAttr("incus_storage_pool.pool1", "driver", "lvm"),
resource.TestCheckResourceAttr("incus_storage_volume.volume1", "name", volumeName),
resource.TestCheckResourceAttr("incus_storage_volume.volume1", "pool", poolName),
resource.TestCheckResourceAttr("incus_storage_volume.volume1", "source_file", "/path/to/volume.backup"),
),
},
{
Config: testAccStorageVolume_sourceFile(poolName, volumeName),
ConfigPlanChecks: resource.ConfigPlanChecks{
PreApply: []plancheck.PlanCheck{
plancheck.ExpectEmptyPlan(),
},
},
},
},
})
}

func testAccStorageVolume_basic(poolName, volumeName string) string {
return fmt.Sprintf(`
resource "incus_storage_pool" "pool1" {
Expand Down Expand Up @@ -369,3 +401,19 @@ resource "incus_storage_volume" "volume1_copy" {
`,
poolName, volumeName)
}

func testAccStorageVolume_sourceFile(poolName, volumeName string) string {
return fmt.Sprintf(`
resource "incus_storage_pool" "pool1" {
name = "%[1]s"
driver = "lvm"
}
resource "incus_storage_volume" "volume1" {
name = "%[2]s"
pool = incus_storage_pool.pool1.name
source_file = "/path/to/volume.backup"
}
`,
poolName, volumeName)
}

0 comments on commit 2bb7dc8

Please sign in to comment.