2023-05-13 10:46:43 +00:00
|
|
|
package cache
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"code.dumpstack.io/tools/out-of-tree/fs"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestDownloadQemuImage(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 = DownloadQemuImage(tmp, file)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !fs.PathExists(filepath.Join(tmp, file)) {
|
|
|
|
t.Fatalf("%s does not exist", file)
|
|
|
|
}
|
|
|
|
}
|
2023-05-13 12:36:19 +00:00
|
|
|
|
|
|
|
func TestDownloadDebianCache(t *testing.T) {
|
|
|
|
tmp, err := ioutil.TempDir("", "out-of-tree_")
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
defer os.RemoveAll(tmp)
|
|
|
|
|
|
|
|
file := "debian.cache"
|
|
|
|
|
|
|
|
cachePath := filepath.Join(tmp, file)
|
|
|
|
|
|
|
|
err = DownloadDebianCache(cachePath)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if !fs.PathExists(filepath.Join(tmp, file)) {
|
|
|
|
t.Fatalf("%s does not exist", file)
|
|
|
|
}
|
|
|
|
}
|