forked from longtao.wu/droboticflow
48 lines
1.9 KiB
Go
48 lines
1.9 KiB
Go
package api
|
|
|
|
import (
|
|
"context"
|
|
"droboticflow/internal/domain"
|
|
"droboticflow/internal/store"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
type deliveryProbeBrowser struct{ objectStorageBrowser }
|
|
|
|
func (deliveryProbeBrowser) PutObject(context.Context, string, string, []byte, string) (domain.ObjectStorageObjectSummary, error) {
|
|
return domain.ObjectStorageObjectSummary{}, nil
|
|
}
|
|
func (deliveryProbeBrowser) DeleteObject(context.Context, string, string) error { return nil }
|
|
|
|
func TestCaptureDeliveryConfigRejectsOverlap(t *testing.T) {
|
|
workflow := &domain.WorkflowRecord{Type: domain.WorkflowTypeStreaming, DefinitionState: domain.WorkflowDefinitionStateReleased, WorkflowInputs: []domain.WorkflowInputDefinition{{ID: "sourceDirectory"}}}
|
|
for _, prefix := range []string{"raw", "raw/outputs", "system/runs", ""} {
|
|
config := normalizeCaptureAutomationConfig(domain.CaptureAutomationConfig{Enabled: true, ConnectionID: "c", Bucket: "b", Prefix: "raw", DeliveryPrefix: prefix})
|
|
issues := validateCaptureAutomationConfig(workflow, config)
|
|
found := false
|
|
for _, i := range issues {
|
|
if strings.Contains(i.Field, "deliveryPrefix") {
|
|
found = true
|
|
}
|
|
}
|
|
if !found {
|
|
t.Fatal(prefix, issues)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestProjectDeletionProtectsFrozenDelivery(t *testing.T) {
|
|
ctx := context.Background()
|
|
db := store.NewMemoryStore()
|
|
s := &server{store: db}
|
|
d := &domain.CaptureDeliveryTarget{ConnectionID: "c", Bucket: "b", Prefix: "deliveries/project/capture"}
|
|
if e := db.UpsertCaptureRecord(ctx, domain.CaptureRecord{ID: "capture", OrganizationID: "org", WorkflowID: "w", Delivery: d}); e != nil {
|
|
t.Fatal(e)
|
|
}
|
|
plan := domain.ProjectDeletionPlan{OrganizationID: "org", Targets: []domain.ProjectDeletionTarget{{Kind: "bos", ConnectionID: "c", Bucket: "b", Prefix: "deliveries/project"}}}
|
|
if e := s.validateDeletionReferences(ctx, plan); e == nil || !strings.Contains(e.Error(), "交付") {
|
|
t.Fatal(e)
|
|
}
|
|
}
|