-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Alejandro JNM <alejandrojnm@gmail.com>
- Loading branch information
1 parent
efbfce8
commit 12c41ce
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package civo | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest" | ||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource" | ||
) | ||
|
||
func TestAccDataSourceCivoSnapshots_basic(t *testing.T) { | ||
datasourceName := "data.civo_snapshot.foobar" | ||
name := acctest.RandomWithPrefix("snapshot-test") | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccDataSourceCivoSnapshotsConfig(name), | ||
Check: resource.ComposeAggregateTestCheckFunc( | ||
resource.TestCheckResourceAttr(datasourceName, "name", name), | ||
resource.TestCheckResourceAttrSet(datasourceName, "hostname"), | ||
resource.TestCheckResourceAttrSet(datasourceName, "size_gb"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccDataSourceCivoSnapshotsConfig(name string) string { | ||
return fmt.Sprintf(` | ||
resource "civo_instance" "vm" { | ||
hostname = "instance-%s" | ||
} | ||
resource "civo_snapshot" "foobar" { | ||
name = "%s" | ||
instance_id = civo_instance.vm.id | ||
} | ||
data "civo_snapshot" "foobar" { | ||
name = civo_snapshot.foobar.name | ||
} | ||
`, name, name) | ||
} |