task 4
This commit is contained in:
@@ -17,6 +17,35 @@ import (
|
||||
"git.westgate.pw/ShadowsOverWestgate/sow-tools/internal/project"
|
||||
)
|
||||
|
||||
func TestBuildHAKsCleansFailedTemporaryArchive(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
p := loadDirectProject(t, root)
|
||||
|
||||
blobs := filepath.Join(root, "blobs")
|
||||
sha := strings.Repeat("a", 64)
|
||||
writeBlobAt(t, blobs, sha, "wxyz")
|
||||
manifestPath := writeDirectManifest(t, root,
|
||||
map[string]SourceAsset{"core/a.tga": {SHA256: sha, SizeBytes: 4}},
|
||||
[]string{"core/a.tga"})
|
||||
|
||||
tmpPath := filepath.Join(root, "build", "core_01.hak.tmp")
|
||||
mustWriteFile(t, tmpPath, "stale partial archive")
|
||||
|
||||
_, err := BuildHAKsWithOptions(p, BuildHAKOptions{
|
||||
SourceManifestPath: manifestPath,
|
||||
ContentAddressedRoot: blobs,
|
||||
})
|
||||
if err == nil {
|
||||
t.Fatal("expected corrupt input to fail")
|
||||
}
|
||||
if _, err := os.Stat(filepath.Join(root, "build", "core_01.hak")); !errors.Is(err, os.ErrNotExist) {
|
||||
t.Fatal("corrupt input must not leave a completed hak")
|
||||
}
|
||||
if _, err := os.Stat(tmpPath); !errors.Is(err, os.ErrNotExist) {
|
||||
t.Fatal("failed build must clean temporary hak")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildThenExtract(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
mustMkdir(t, filepath.Join(root, "src"))
|
||||
|
||||
Reference in New Issue
Block a user