Allow deleting draft server records
This commit is contained in:
@@ -986,7 +986,7 @@ func validateServerInstance(instance domain.ServerInstance, allowDeleted bool) e
|
||||
violations = appendRequired(violations, "id", instance.ID)
|
||||
violations = appendRequired(violations, "pluginId", instance.PluginID)
|
||||
violations = appendRequired(violations, "pluginVersion", instance.PluginVersion)
|
||||
if instance.State != domain.ServerInstanceStateDraft {
|
||||
if instance.State != domain.ServerInstanceStateDraft && instance.State != domain.ServerInstanceStateDeleted {
|
||||
violations = appendRequired(violations, "runEndpointId", instance.RunEndpointID)
|
||||
}
|
||||
violations = appendRequired(violations, "name", instance.Name)
|
||||
|
||||
@@ -287,6 +287,20 @@ func TestValidateServerInstanceRejectsDeletedCreateState(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateStoredServerInstanceAllowsDeletedWithoutRunEndpoint(t *testing.T) {
|
||||
instance := domain.ServerInstance{
|
||||
ID: "server-1",
|
||||
PluginID: "server.scum",
|
||||
PluginVersion: "1.0.0",
|
||||
Name: "SCUM #1",
|
||||
State: domain.ServerInstanceStateDeleted,
|
||||
}
|
||||
|
||||
if err := ValidateStoredServerInstance(instance); err != nil {
|
||||
t.Fatalf("expected stored deleted instance without run endpoint to validate, got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateJobBoundsProgress(t *testing.T) {
|
||||
job := domain.Job{
|
||||
ID: "job-1",
|
||||
|
||||
Reference in New Issue
Block a user