e11bc6f3d6
Core delivery service with: task creation (idempotent, validated), background scheduler (claimAndReserve with SELECT FOR UPDATE SKIP LOCKED), 4-level concurrency control, resource quota enforcement, host allocation from candidate pool, AWX job dispatch, polling, TCP health check, instance registration, CloudDM integration (optional), and cancel support. 11-state machine with optimistic locking and full event audit trail. Relates-to: #97
28 lines
786 B
Go
28 lines
786 B
Go
package service
|
|
|
|
import "testing"
|
|
|
|
func TestValidateDeliveryInput(t *testing.T) {
|
|
valid := MySQLDeliveryInput{BusinessLineID: 1, TargetID: 1, Namespace: "team-a", InstanceName: "mysql-01", CPUMilli: 500, MemoryMi: 1024, StorageGi: 10}
|
|
if err := validateDeliveryInput(valid); err != nil {
|
|
t.Fatalf("valid input rejected: %v", err)
|
|
}
|
|
for name, input := range map[string]MySQLDeliveryInput{
|
|
"uppercase namespace": valid,
|
|
"bad instance": valid,
|
|
"too little memory": valid,
|
|
} {
|
|
switch name {
|
|
case "uppercase namespace":
|
|
input.Namespace = "Team-A"
|
|
case "bad instance":
|
|
input.InstanceName = "mysql_01"
|
|
case "too little memory":
|
|
input.MemoryMi = 128
|
|
}
|
|
if err := validateDeliveryInput(input); err == nil {
|
|
t.Errorf("%s was accepted", name)
|
|
}
|
|
}
|
|
}
|