This commit is contained in:
@@ -15,7 +15,7 @@ type CatalogSource struct {
|
||||
LastRefreshDurationMS int64 `json:"last_refresh_duration_ms"`
|
||||
// ScanProgress / ScanMessage 只在 SnapshotStatus == "scanning" 时有值:新来源在首次扫描
|
||||
// 完成前也出现在「来源与目录」里,带着百分比与进度文案,不必等到快照落地才看得见。
|
||||
ScanProgress int `json:"scan_progress,omitempty"`
|
||||
ScanProgress int `json:"scan_progress"`
|
||||
ScanMessage string `json:"scan_message,omitempty"`
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package governance
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestQueuedCatalogSourceIncludesNumericZeroProgress(t *testing.T) {
|
||||
source := CatalogSource{SnapshotStatus: "scanning", ScanProgress: 0}
|
||||
body, err := json.Marshal(source)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var decoded map[string]any
|
||||
if err = json.Unmarshal(body, &decoded); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if value, ok := decoded["scan_progress"]; !ok || value != float64(0) {
|
||||
t.Fatalf("queued source must satisfy the frontend numeric progress contract: %s", body)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user