From 2977b6f7fdf58fda721c2d0b2c39f551c6ccdde0 Mon Sep 17 00:00:00 2001 From: Mikhail Klementev Date: Sat, 13 May 2023 09:31:25 +0000 Subject: [PATCH] test: add download image test --- images_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 images_test.go diff --git a/images_test.go b/images_test.go new file mode 100644 index 0000000..f86bc0f --- /dev/null +++ b/images_test.go @@ -0,0 +1,29 @@ +package main + +import ( + "io/ioutil" + "os" + "path/filepath" + "testing" + + "code.dumpstack.io/tools/out-of-tree/fs" +) + +func TestDownloadImage(t *testing.T) { + tmp, err := ioutil.TempDir("", "out-of-tree_") + if err != nil { + return + } + defer os.RemoveAll(tmp) + + file := "out_of_tree_ubuntu_12__04.img" + + err = downloadImage(tmp, file) + if err != nil { + t.Fatal(err) + } + + if !fs.PathExists(filepath.Join(tmp, file)) { + t.Fatalf("%s does not exist", file) + } +}