Packaging Fix
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package topdata
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
@@ -9670,7 +9671,8 @@ func TestBuildAndPackageIncludesCompiled2DAAndTopAssets(t *testing.T) {
|
||||
"columns": ["Label"],
|
||||
"rows": [{"id": 0, "Label": "TEST_LABEL"}]
|
||||
}`+"\n")
|
||||
writeFile(t, filepath.Join(root, "topdata", "assets", "gui", "testicon.png"), "icon-data")
|
||||
pngPayload := bytes.Repeat([]byte("png-payload-"), 4096)
|
||||
writeBytes(t, filepath.Join(root, "topdata", "assets", "gui", "testicon.png"), pngPayload)
|
||||
|
||||
proj := testProject(root)
|
||||
proj.Config.TopData.ReferenceBuilder = ""
|
||||
@@ -9708,6 +9710,9 @@ func TestBuildAndPackageIncludesCompiled2DAAndTopAssets(t *testing.T) {
|
||||
found2DA = true
|
||||
}
|
||||
if key == "testicon.png" {
|
||||
if !bytes.Equal(resource.Data, pngPayload) {
|
||||
t.Fatalf("expected testicon.png payload to be preserved, got %d bytes", len(resource.Data))
|
||||
}
|
||||
foundAsset = true
|
||||
}
|
||||
if ext == "tlk" {
|
||||
@@ -9728,6 +9733,22 @@ func TestBuildAndPackageIncludesCompiled2DAAndTopAssets(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCollectTopPackageResourcesRejectsDuplicateTopAssetKeys(t *testing.T) {
|
||||
root := testProjectRoot(t)
|
||||
mkdirAll(t, filepath.Join(root, ".cache", "2da"))
|
||||
mkdirAll(t, filepath.Join(root, "topdata", "assets", "gui", "icons"))
|
||||
mkdirAll(t, filepath.Join(root, "topdata", "assets", "gui", "portraits"))
|
||||
writeFile(t, filepath.Join(root, "topdata", "base_dialog.json"), "{}\n")
|
||||
writeFile(t, filepath.Join(root, ".cache", "2da", "repadjust.2da"), "2DA V2.0\n\n Label\n0 TEST_LABEL\n")
|
||||
writeFile(t, filepath.Join(root, "topdata", "assets", "gui", "icons", "duplicate.png"), "icon-a")
|
||||
writeFile(t, filepath.Join(root, "topdata", "assets", "gui", "portraits", "duplicate.png"), "icon-b")
|
||||
|
||||
proj := testProject(root)
|
||||
if _, _, err := collectTopPackageResources(proj, filepath.Join(root, ".cache", "2da")); err == nil || !strings.Contains(err.Error(), "collides with") {
|
||||
t.Fatalf("expected duplicate topdata asset collision, got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildAndPackageHonorsConfiguredTopPackageOutputNames(t *testing.T) {
|
||||
root := testProjectRoot(t)
|
||||
mkdirAll(t, filepath.Join(root, "topdata", "data", "repadjust"))
|
||||
@@ -10214,3 +10235,10 @@ func writeFile(t *testing.T, path, content string) {
|
||||
t.Fatalf("write %s: %v", path, err)
|
||||
}
|
||||
}
|
||||
|
||||
func writeBytes(t *testing.T, path string, content []byte) {
|
||||
t.Helper()
|
||||
if err := os.WriteFile(path, content, 0o755); err != nil {
|
||||
t.Fatalf("write %s: %v", path, err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user