diff --git a/fwprovider/tests/resource_file_test.go b/fwprovider/tests/resource_file_test.go index 466b201b..3e0ce6d6 100644 --- a/fwprovider/tests/resource_file_test.go +++ b/fwprovider/tests/resource_file_test.go @@ -23,6 +23,8 @@ import ( "github.com/bpg/terraform-provider-proxmox/proxmox/api" "github.com/bpg/terraform-provider-proxmox/proxmox/ssh" + resourceSsh "github.com/bpg/terraform-provider-proxmox/proxmoxtf/resource/ssh" + "github.com/bpg/terraform-provider-proxmox/utils" ) @@ -144,13 +146,22 @@ func uploadSnippetFile(t *testing.T, file *os.File) { defer f.Close() - err = sshClient.NodeUpload(context.Background(), "pve", "/var/lib/vz", + fname := filepath.Base(file.Name()) + err = sshClient.NodeUpload(context.Background(), "pve", "/tmp/tfpve/testacc", &api.FileUploadRequest{ ContentType: "snippets", - FileName: filepath.Base(file.Name()), + FileName: fname, File: f, }) require.NoError(t, err) + + _, err = sshClient.ExecuteNodeCommands(context.Background(), "pve", []string{ + fmt.Sprintf(`%s; try_sudo "mv /tmp/tfpve/testacc/snippets/%s /var/lib/vz/snippets/%s" && rm -rf /tmp/tfpve/testacc/`, + resourceSsh.TrySudo, + fname, fname, + ), + }) + require.NoError(t, err) } func createFile(t *testing.T, namePattern string, content string) *os.File {