Clear Old Assets Path

This commit is contained in:
2026-04-18 11:02:38 +02:00
parent 5e900d00b5
commit b6ed92e3e8
2 changed files with 32 additions and 20 deletions
+26 -6
View File
@@ -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)
}
}