Clear Old Assets Path
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package project
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
@@ -82,7 +83,7 @@ func TestTopDataAssetsDirReturnsEmptyForNoConfig(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateLayoutCreatesMissingCacheAssetsDir(t *testing.T) {
|
||||
func TestValidateLayoutAllowsMissingAssetsDir(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
mkdirAll(t, filepath.Join(root, "src"))
|
||||
mkdirAll(t, filepath.Join(root, "build"))
|
||||
@@ -91,17 +92,36 @@ func TestValidateLayoutCreatesMissingCacheAssetsDir(t *testing.T) {
|
||||
Root: root,
|
||||
Config: Config{
|
||||
Module: ModuleConfig{Name: "Test", ResRef: "test"},
|
||||
Paths: PathConfig{Source: "src", Assets: ".cache/module-assets", Build: "build"},
|
||||
Paths: PathConfig{Source: "src", Assets: "assets", Build: "build"},
|
||||
},
|
||||
}
|
||||
|
||||
if err := proj.ValidateLayout(); err != nil {
|
||||
t.Fatalf("ValidateLayout returned error: %v", err)
|
||||
}
|
||||
if info, err := os.Stat(filepath.Join(root, ".cache", "module-assets")); err != nil {
|
||||
t.Fatalf("expected cache assets dir to be created: %v", err)
|
||||
} else if !info.IsDir() {
|
||||
t.Fatalf("expected cache assets path to be a directory")
|
||||
if _, err := os.Stat(filepath.Join(root, "assets")); !errors.Is(err, os.ErrNotExist) {
|
||||
t.Fatalf("expected missing assets dir to remain absent, got err=%v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestScanAllowsMissingAssetsDir(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
mkdirAll(t, filepath.Join(root, "src"))
|
||||
mkdirAll(t, filepath.Join(root, "build"))
|
||||
|
||||
proj := &Project{
|
||||
Root: root,
|
||||
Config: Config{
|
||||
Module: ModuleConfig{Name: "Test", ResRef: "test"},
|
||||
Paths: PathConfig{Source: "src", Assets: "assets", Build: "build"},
|
||||
},
|
||||
}
|
||||
|
||||
if err := proj.Scan(); err != nil {
|
||||
t.Fatalf("Scan returned error: %v", err)
|
||||
}
|
||||
if len(proj.Inventory.AssetFiles) != 0 {
|
||||
t.Fatalf("expected no asset files, got %#v", proj.Inventory.AssetFiles)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user