1
0
out-of-tree/cache/cache_test.go

50 lines
802 B
Go
Raw Normal View History

2023-05-13 10:46:43 +00:00
package cache
import (
"os"
"path/filepath"
"testing"
"code.dumpstack.io/tools/out-of-tree/fs"
)
2023-06-15 15:24:29 +00:00
func TestDownloadRootFS(t *testing.T) {
2024-02-20 12:38:36 +00:00
tmp, err := os.MkdirTemp("", "out-of-tree_")
2023-05-13 10:46:43 +00:00
if err != nil {
return
}
defer os.RemoveAll(tmp)
file := "out_of_tree_ubuntu_12__04.img"
2023-06-15 15:24:29 +00:00
err = DownloadRootFS(tmp, file)
2023-05-13 10:46:43 +00:00
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) {
2023-05-13 12:50:26 +00:00
tmp, err := fs.TempDir()
2023-05-13 12:36:19 +00:00
if err != nil {
return
}
defer os.RemoveAll(tmp)
file := "debian.cache"
cachePath := filepath.Join(tmp, file)
err = DownloadDebianCache(cachePath)
if err != nil {
2023-05-13 12:40:36 +00:00
t.Fatal(err)
2023-05-13 12:36:19 +00:00
}
if !fs.PathExists(filepath.Join(tmp, file)) {
t.Fatalf("%s does not exist", file)
}
}