feat(t216): deliver recoverable device order commands
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package usecase
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"cmroubao/backend-api/internal/domain"
|
||||
)
|
||||
|
||||
func TestDeviceOrderCommandSHA256MatchesMobileContractVector(t *testing.T) {
|
||||
command := domain.DeviceOrderCommand{
|
||||
ID: "00000000-0000-4000-8000-000000000009",
|
||||
SchemaVersion: 1,
|
||||
Type: "CREATE_PENDING_ORDER",
|
||||
AuthorizationVersion: 3,
|
||||
TaskID: "00000000-0000-4000-8000-000000000001",
|
||||
ExecutionID: "00000000-0000-4000-8000-000000000002",
|
||||
TaskContentSHA256: repeatForCommandTest("a"),
|
||||
OriginalSKU: "红色 M",
|
||||
Quantity: 2,
|
||||
CandidateKey: "candidate-key-1",
|
||||
ObservedOrdinal: 1,
|
||||
CandidateTitle: "红色连衣裙",
|
||||
CandidateSKUText: "红色 / M",
|
||||
CandidatePriceText: "19.90 CNY",
|
||||
CardSignature: repeatForCommandTest("b"),
|
||||
DetailSignature: repeatForCommandTest("c"),
|
||||
DetailEvidenceSHA256: repeatForCommandTest("d"),
|
||||
SpecificationEvidenceSHA256: repeatForCommandTest("e"),
|
||||
}
|
||||
|
||||
got, err := DeviceOrderCommandSHA256(command)
|
||||
if err != nil {
|
||||
t.Fatalf("DeviceOrderCommandSHA256() error = %v", err)
|
||||
}
|
||||
const want = "cf3cd802366d4de49d51940551385f7e5bd3283ef18cbf245a227c679d1058f3"
|
||||
if got != want {
|
||||
t.Fatalf("DeviceOrderCommandSHA256() = %q, want %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func repeatForCommandTest(value string) string {
|
||||
result := ""
|
||||
for len(result) < 64 {
|
||||
result += value
|
||||
}
|
||||
return result
|
||||
}
|
||||
Reference in New Issue
Block a user