补齐空部署目标防护与进度清单

This commit is contained in:
xuans committed 2026-09-30 06:04:54 +08:00
1 parent 9414b5c5d8
commit cb88602882
8 files changed
+77

No files matched your search

+4
View File
@@ -57,6 +57,10 @@ func NewService(factory ClientFactory) *Service {
func (s *Service) Deploy(ctx context.Context, targets []Target, artifact Artifact) Report {
report := Report{Total: len(targets), Results: make([]Result, 0, len(targets))}
if len(targets) == 0 {
report.Status = "failed"
return report
}
if s == nil || s.factory == nil {
report.Status = "failed"
report.Failed = len(targets)
@@ -269,6 +269,14 @@ func TestDeployReportsPartialSuccess(t *testing.T) {
}
}
func TestDeployRejectsEmptyTargets(t *testing.T) {
service := NewService(fixedClientFactory{client: newMemoryClient()})
report := service.Deploy(context.Background(), nil, testArtifact(t))
if report.Status != "failed" || report.Total != 0 || report.Success != 0 || report.Failed != 0 {
t.Fatalf("\u7a7a\u90e8\u7f72\u76ee\u6807\u4e0d\u5f97\u88ab\u89c6\u4e3a\u6210\u529f\xef\xbc\x9a%+v", report)
}
}
func TestDeployCleansPartialPrivateKeyUploadWithoutReplacingCurrentFiles(t *testing.T) {
client := newMemoryClient()
client.uploadError = "key.pem"