完善生图5.0的功能
This commit is contained in:
1 parent
88a4268d40
commit
678d213f40
31 files changed
+3281
-107
No files matched your search
@@ -102,6 +102,28 @@ func TestSettlementProcessorLeavesNonSeedanceSuccessAlone(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSettlementProcessorRefundsUnusedSeedreamLayerReservation(t *testing.T) {
|
||||
state := &settlementStateStub{}
|
||||
ledger := &settlementLedgerStub{posting: billing.WalletPosting{LedgerID: "layer-settlement", CreatedAt: time.Date(2026, 8, 21, 8, 0, 0, 0, time.UTC)}}
|
||||
advanced := jobs.Job{
|
||||
ID: "layer-job", Provider: "seedream", ReqKey: billing.Seedream50ProModel, Capability: "image.generate", Status: jobs.StatusSucceeded,
|
||||
RequestPayload: json.RawMessage(`{"settings":{"creationMode":"layers","layerDecomposition":true,"size":"2K"}}`),
|
||||
ResponsePayload: json.RawMessage(`{"status":"succeeded","raw":{"data":[{"size":"2048x2048","z_index":0},{"size":"1273x265","z_index":1}]}}`),
|
||||
Billing: json.RawMessage(`{"status":"charged","amountFen":612,"reservedAmountFen":612,"markupMultiplier":1.2,"settlementStatus":"pending"}`),
|
||||
UsageContext: json.RawMessage(`{"organizationId":"org-1","accountId":"account-1"}`),
|
||||
}
|
||||
processor := NewSettlementProcessor(settlementProcessorStub{job: advanced}, ledger, state, time.Now)
|
||||
got, err := processor.Advance(context.Background(), jobs.Job{ID: "layer-job", Provider: "seedream", Status: jobs.StatusRunning})
|
||||
if err != nil || ledger.calls != 1 || ledger.request.DeltaFen != -558 || ledger.request.Metadata["actualAmountFen"] != int64(54) {
|
||||
t.Fatalf("job=%#v request=%#v calls=%d err=%v", got, ledger.request, ledger.calls, err)
|
||||
}
|
||||
var snapshot map[string]any
|
||||
_ = json.Unmarshal(got.Billing, &snapshot)
|
||||
if snapshot["amountFen"] != float64(54) || snapshot["settlementStatus"] != "settled" || snapshot["settlementLedgerEntryId"] != "layer-settlement" {
|
||||
t.Fatalf("billing snapshot=%#v", snapshot)
|
||||
}
|
||||
}
|
||||
|
||||
func seedanceSettlementJob(response, billingJSON string) jobs.Job {
|
||||
return jobs.Job{
|
||||
ID: "job-1", Provider: "seedance", Capability: "video.generate", Status: jobs.StatusSucceeded,
|
||||
|
||||
Reference in new issue
Block a user