Skip to content

Commit

Permalink
internal/instance: Add test for custom image server
Browse files Browse the repository at this point in the history
Signed-off-by: Din Music <[email protected]>
  • Loading branch information
MusicDin committed May 21, 2024
1 parent b11d254 commit 7ba4db0
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions internal/instance/resource_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,24 @@ func TestAccInstance_removeProject(t *testing.T) {
})
}

func TestAccInstance_customImageServer(t *testing.T) {
instanceName := acctest.GenerateName(2, "-")

resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
ProtoV6ProviderFactories: acctest.ProtoV6ProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccInstance_customImageServer(instanceName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("lxd_instance.instance1", "name", instanceName),
resource.TestCheckResourceAttr("lxd_instance.instance1", "status", "Running"),
),
},
},
})
}

func TestAccInstance_timeout(t *testing.T) {
instanceName := acctest.GenerateName(2, "-")

Expand Down Expand Up @@ -2037,6 +2055,23 @@ resource "lxd_instance" "instance1" {
`, projectName, instanceName, acctest.TestImage)
}

func testAccInstance_customImageServer(instanceName string) string {
return fmt.Sprintf(`
provider "lxd" {
remote {
name = "images-temporary"
address = "images.lxd.canonical.com"
protocol = "simplestreams"
}
}
resource "lxd_instance" "instance1" {
name = "%s"
image = "images-temporary:alpine/edge"
}
`, instanceName)
}

func testAccInstance_timeout(instanceName string) string {
return fmt.Sprintf(`
resource "lxd_instance" "instance1" {
Expand Down

0 comments on commit 7ba4db0

Please sign in to comment.