feat(t214): persist candidate observation identities

This commit is contained in:
QiuSW
2026-07-28 12:21:55 +08:00
parent acd3c85b5b
commit 56e7a2be33
29 changed files with 622 additions and 94 deletions
@@ -17,6 +17,7 @@ import (
"testing"
"time"
"cmroubao/backend-api/internal/domain"
"cmroubao/backend-api/internal/platform/assetstore"
"cmroubao/backend-api/internal/platform/database"
"cmroubao/backend-api/internal/platform/migration"
@@ -26,6 +27,37 @@ import (
"github.com/gin-gonic/gin"
)
func TestCandidateDecisionDatasetResponseIncludesPersistentIdentity(t *testing.T) {
createdAt := time.Date(2026, 7, 28, 12, 0, 0, 0, time.UTC)
response := candidateDecisionDatasetResponse(&domain.CandidateDecisionDataset{
Observations: []domain.CandidateObservation{
{
Ordinal: 1,
Identity: &domain.CandidateObservationIdentity{
CandidateKey: strings.Repeat("a", 64),
CardSignature: strings.Repeat("b", 64),
DetailSignature: strings.Repeat("c", 64),
DetailEvidenceSHA256: strings.Repeat("d", 64),
SpecificationEvidenceSHA256: strings.Repeat("e", 64),
IdentityVersion: 1,
CreatedAt: createdAt,
},
},
},
})
observations, ok := response["observations"].([]gin.H)
if !ok || len(observations) != 1 {
t.Fatalf("observations = %#v", response["observations"])
}
identity, ok := observations[0]["identity"].(gin.H)
if !ok ||
identity["candidate_key"] != strings.Repeat("a", 64) ||
identity["identity_version"] != 1 {
t.Fatalf("identity = %#v", observations[0]["identity"])
}
}
func TestAdminAPIAssetAndTaskLifecycle(t *testing.T) {
router := newAdminIntegrationRouter(t)
imageBody, imageContentType := referenceUpload(t, "asset-key-1")