mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-06-30 02:31:10 +00:00
tests: add tests for content type "import"
Signed-off-by: Marco Attia <54147992+Vaneixus@users.noreply.github.com>
This commit is contained in:
parent
e1d8cb097a
commit
504add02f6
@ -20,3 +20,13 @@ resource "proxmox_virtual_environment_download_file" "latest_debian_12_bookworm_
|
||||
overwrite = true
|
||||
overwrite_unmanaged = true
|
||||
}
|
||||
|
||||
resource "proxmox_virtual_environment_download_file" "latest_debian_12_bookworm_qcow2_img" {
|
||||
content_type = "import"
|
||||
datastore_id = "local"
|
||||
file_name = "debian-12-generic-amd64.qcow2"
|
||||
node_name = "pve"
|
||||
url = var.latest_debian_12_bookworm_qcow2_img_url
|
||||
overwrite = true
|
||||
overwrite_unmanaged = true
|
||||
}
|
||||
|
@ -8,6 +8,16 @@ resource "proxmox_virtual_environment_download_file" "release_20231228_debian_12
|
||||
checksum_algorithm = "sha512"
|
||||
}
|
||||
|
||||
resource "proxmox_virtual_environment_download_file" "release_20231228_debian_12_bookworm_qcow2" {
|
||||
content_type = "import"
|
||||
datastore_id = "local"
|
||||
file_name = "debian-12-generic-amd64-20231228-1609"
|
||||
node_name = "pve"
|
||||
url = "https://cloud.debian.org/images/cloud/bookworm/20231228-1609/debian-12-generic-amd64-20231228-1609.qcow2"
|
||||
checksum = "d2fbcf11fb28795842e91364d8c7b69f1870db09ff299eb94e4fbbfa510eb78d141e74c1f4bf6dfa0b7e33d0c3b66e6751886feadb4e9916f778bab1776bdf1b"
|
||||
checksum_algorithm = "sha512"
|
||||
}
|
||||
|
||||
resource "proxmox_virtual_environment_download_file" "latest_debian_12_bookworm_qcow2_img" {
|
||||
content_type = "iso"
|
||||
datastore_id = "local"
|
||||
@ -16,6 +26,14 @@ resource "proxmox_virtual_environment_download_file" "latest_debian_12_bookworm_
|
||||
url = "https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-amd64.qcow2"
|
||||
}
|
||||
|
||||
resource "proxmox_virtual_environment_download_file" "latest_debian_12_bookworm_qcow2" {
|
||||
content_type = "import"
|
||||
datastore_id = "local"
|
||||
file_name = "debian-12-generic-amd64.qcow2"
|
||||
node_name = "pve"
|
||||
url = "https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-amd64.qcow2"
|
||||
}
|
||||
|
||||
resource "proxmox_virtual_environment_download_file" "latest_ubuntu_22_jammy_qcow2_img" {
|
||||
content_type = "iso"
|
||||
datastore_id = "local"
|
||||
|
@ -0,0 +1,19 @@
|
||||
resource "proxmox_virtual_environment_file" "latest_debian_12_bookworm_qcow2" {
|
||||
content_type = "import"
|
||||
datastore_id = "local"
|
||||
node_name = "pve"
|
||||
|
||||
source_file {
|
||||
path = "https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-amd64.qcow2"
|
||||
}
|
||||
}
|
||||
|
||||
resource "proxmox_virtual_environment_file" "release_20231228_debian_12_bookworm_qcow2" {
|
||||
content_type = "import"
|
||||
datastore_id = "local"
|
||||
node_name = "pve"
|
||||
|
||||
source_file {
|
||||
path = "https://cloud.debian.org/images/cloud/bookworm/20231228-1609/debian-12-generic-amd64-20231228-1609.qcow2"
|
||||
}
|
||||
}
|
@ -60,7 +60,7 @@ func TestAccResourceDownloadFile(t *testing.T) {
|
||||
}`),
|
||||
ExpectError: regexp.MustCompile(`Attribute url must match HTTP URL regex`),
|
||||
}}},
|
||||
{"download qcow2 file", []resource.TestStep{{
|
||||
{"download qcow2 file to iso storage", []resource.TestStep{{
|
||||
Config: te.RenderConfig(`
|
||||
resource "proxmox_virtual_environment_download_file" "qcow2_image" {
|
||||
content_type = "iso"
|
||||
@ -91,6 +91,38 @@ func TestAccResourceDownloadFile(t *testing.T) {
|
||||
}),
|
||||
),
|
||||
}}},
|
||||
,
|
||||
{"download qcow2 file to import storage", []resource.TestStep{{
|
||||
Config: te.RenderConfig(`
|
||||
resource "proxmox_virtual_environment_download_file" "qcow2_image" {
|
||||
content_type = "import"
|
||||
node_name = "{{.NodeName}}"
|
||||
datastore_id = "{{.DatastoreID}}"
|
||||
file_name = "fake_qcow2_file.qcow2"
|
||||
url = "{{.FakeFileQCOW2}}"
|
||||
checksum = "688787d8ff144c502c7f5cffaafe2cc588d86079f9de88304c26b0cb99ce91c6"
|
||||
checksum_algorithm = "sha256"
|
||||
overwrite_unmanaged = true
|
||||
}`),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
test.ResourceAttributes("proxmox_virtual_environment_download_file.qcow2_image", map[string]string{
|
||||
"id": "local:import/fake_qcow2_file.qcow2",
|
||||
"content_type": "import",
|
||||
"node_name": te.NodeName,
|
||||
"datastore_id": te.DatastoreID,
|
||||
"url": fakeFileQCOW2,
|
||||
"file_name": "fake_qcow2_file.qcow2",
|
||||
"upload_timeout": "600",
|
||||
"size": "3",
|
||||
"verify": "true",
|
||||
"checksum": "688787d8ff144c502c7f5cffaafe2cc588d86079f9de88304c26b0cb99ce91c6",
|
||||
"checksum_algorithm": "sha256",
|
||||
}),
|
||||
test.NoResourceAttributesSet("proxmox_virtual_environment_download_file.qcow2_image", []string{
|
||||
"decompression_algorithm",
|
||||
}),
|
||||
),
|
||||
}}},
|
||||
{"download & update iso file", []resource.TestStep{
|
||||
{
|
||||
Config: te.RenderConfig(`
|
||||
|
@ -118,11 +118,16 @@ func Test_fileParseVolumeID(t *testing.T) {
|
||||
{"missing type", "local:/file.ido", fileVolumeID{}, true},
|
||||
{"missing file", "local:iso", fileVolumeID{}, true},
|
||||
{"missing file", "local:iso/", fileVolumeID{}, true},
|
||||
{"valid", "local:iso/file.iso", fileVolumeID{
|
||||
{"valid iso", "local:iso/file.iso", fileVolumeID{
|
||||
datastoreID: "local",
|
||||
contentType: "iso",
|
||||
fileName: "file.iso",
|
||||
}, false},
|
||||
{"valid import", "local:import/file.qcow2", fileVolumeID{
|
||||
datastoreID: "local",
|
||||
contentType: "import",
|
||||
fileName: "file.qcow2",
|
||||
}, false},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
Loading…
Reference in New Issue
Block a user