forked from mtusi2026/mtusi2026lab6
Prepare verified laboratory 6 implementation and evidence
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package usecase
|
||||
|
||||
import (
|
||||
"backend/internal/domain/model"
|
||||
"backend/internal/domain/port"
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"github.com/google/uuid"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestReconcilerCannotPublishVersionedPipelineResult(t *testing.T) {
|
||||
for _, status := range []string{"uploading", "queued", "processing", "failed", "ready"} {
|
||||
t.Run(status, func(t *testing.T) {
|
||||
id := uuid.New()
|
||||
raw := []byte("only original survived worker crash")
|
||||
sum := sha256.Sum256(raw)
|
||||
repo := &fixtureRepo{rows: map[uuid.UUID]model.Attachment{id: {ID: id, Status: status, PipelineVersion: 1, SizeBytes: int64(len(raw)), SHA256: hex.EncodeToString(sum[:]), CreatedAt: fixedNow.Add(-2 * time.Minute)}}}
|
||||
objects := &fixtureObjects{items: map[string]port.Object{ObjectKey(id): {Key: ObjectKey(id), Size: int64(len(raw)), Modified: fixedNow.Add(-2 * time.Minute)}}, content: raw}
|
||||
report, e := NewReconciler(repo, objects, func() time.Time { return fixedNow }).Run(context.Background(), uuid.Nil, "", time.Minute, true)
|
||||
if e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
if repo.rows[id].Status != status || report.Recovered != 0 || report.Changed != 0 {
|
||||
t.Fatalf("pipeline state was changed by legacy reconciler: status %s -> %s, report %+v", status, repo.rows[id].Status, report)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user