Regenerate local artifacts and invalidate stale receipts
This commit is contained in:
@@ -737,3 +737,28 @@ func TestUnreadableAssetsDoNotClaimAnUnknownWrite(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestFailedRebuildInvalidatesPreviousReceipt(t *testing.T) {
|
||||
const source = `package main
|
||||
import("fmt";"gitea.maximumdirect.net/eric/ReleaseKit/buildinfo")
|
||||
func main(){fmt.Println("fixture",buildinfo.Version())}
|
||||
`
|
||||
repository := newCLIBuildRepository(t, source)
|
||||
var stdout, stderr bytes.Buffer
|
||||
args := []string{"build", "--repo", repository, "v1.2.3"}
|
||||
for attempt := 0; attempt < 2; attempt++ {
|
||||
if status := run(context.Background(), args, &stdout, &stderr); status != 0 {
|
||||
t.Fatalf("build %d: status=%d %s", attempt, status, stderr.String())
|
||||
}
|
||||
}
|
||||
path := filepath.Join(repository, "cmd/app/main.go")
|
||||
if err := os.WriteFile(path, []byte("package main\nfunc main(){}\n"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if status := run(context.Background(), args, &stdout, &stderr); status != 1 {
|
||||
t.Fatalf("failed rebuild status=%d", status)
|
||||
}
|
||||
if _, err := os.Stat(filepath.Join(repository, "dist", cli.BuildReceiptName)); !os.IsNotExist(err) {
|
||||
t.Fatalf("stale receipt remains: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user