Skip to content

Commit baa0bb8

Browse files
Copilotintel352
andauthored
fix: check all errors in Phase C store tests (#140)
* Initial plan * fix: check all errors in Phase C store tests per review feedback Co-authored-by: intel352 <77607+intel352@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
1 parent 14fb1c9 commit baa0bb8

1 file changed

Lines changed: 84 additions & 24 deletions

File tree

module/api_v1_test.go

Lines changed: 84 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -724,16 +724,28 @@ func TestV1Handler_Projects(t *testing.T) {
724724
func TestV1Store_ExecutionLifecycle(t *testing.T) {
725725
store := setupTestStore(t)
726726

727-
company, _ := store.CreateCompany("Co", "", "u1")
728-
org, _ := store.CreateOrganization(company.ID, "Org", "", "u1")
729-
proj, _ := store.CreateProject(org.ID, "Proj", "", "")
730-
wf, _ := store.CreateWorkflow(proj.ID, "WF", "", "", "modules: []", "u1")
727+
company, err := store.CreateCompany("Co", "", "u1")
728+
if err != nil {
729+
t.Fatalf("CreateCompany: %v", err)
730+
}
731+
org, err := store.CreateOrganization(company.ID, "Org", "", "u1")
732+
if err != nil {
733+
t.Fatalf("CreateOrganization: %v", err)
734+
}
735+
proj, err := store.CreateProject(org.ID, "Proj", "", "")
736+
if err != nil {
737+
t.Fatalf("CreateProject: %v", err)
738+
}
739+
wf, err := store.CreateWorkflow(proj.ID, "WF", "", "", "modules: []", "u1")
740+
if err != nil {
741+
t.Fatalf("CreateWorkflow: %v", err)
742+
}
731743

732744
now := time.Now().UTC()
733745
execID := "exec-001"
734746

735747
// Insert execution
736-
err := store.InsertExecution(execID, wf.ID, "manual", "pending", "u1", now)
748+
err = store.InsertExecution(execID, wf.ID, "manual", "pending", "u1", now)
737749
if err != nil {
738750
t.Fatalf("InsertExecution: %v", err)
739751
}
@@ -776,17 +788,31 @@ func TestV1Store_ExecutionLifecycle(t *testing.T) {
776788
func TestV1Store_ExecutionStepLifecycle(t *testing.T) {
777789
store := setupTestStore(t)
778790

779-
company, _ := store.CreateCompany("Co", "", "u1")
780-
org, _ := store.CreateOrganization(company.ID, "Org", "", "u1")
781-
proj, _ := store.CreateProject(org.ID, "Proj", "", "")
782-
wf, _ := store.CreateWorkflow(proj.ID, "WF", "", "", "modules: []", "u1")
791+
company, err := store.CreateCompany("Co", "", "u1")
792+
if err != nil {
793+
t.Fatalf("CreateCompany: %v", err)
794+
}
795+
org, err := store.CreateOrganization(company.ID, "Org", "", "u1")
796+
if err != nil {
797+
t.Fatalf("CreateOrganization: %v", err)
798+
}
799+
proj, err := store.CreateProject(org.ID, "Proj", "", "")
800+
if err != nil {
801+
t.Fatalf("CreateProject: %v", err)
802+
}
803+
wf, err := store.CreateWorkflow(proj.ID, "WF", "", "", "modules: []", "u1")
804+
if err != nil {
805+
t.Fatalf("CreateWorkflow: %v", err)
806+
}
783807

784808
now := time.Now().UTC()
785809
execID := "exec-step-001"
786-
_ = store.InsertExecution(execID, wf.ID, "manual", "running", "u1", now)
810+
if err = store.InsertExecution(execID, wf.ID, "manual", "running", "u1", now); err != nil {
811+
t.Fatalf("InsertExecution: %v", err)
812+
}
787813

788814
stepID := "step-001"
789-
err := store.InsertExecutionStep(stepID, execID, "parse-request", "step.request_parse", "running", 0, now)
815+
err = store.InsertExecutionStep(stepID, execID, "parse-request", "step.request_parse", "running", 0, now)
790816
if err != nil {
791817
t.Fatalf("InsertExecutionStep: %v", err)
792818
}
@@ -832,9 +858,14 @@ func TestV1Store_ExecutionStepLifecycle(t *testing.T) {
832858
var ids []string
833859
for rows.Next() {
834860
var id string
835-
rows.Scan(&id)
861+
if err := rows.Scan(&id); err != nil {
862+
t.Fatalf("scan step id: %v", err)
863+
}
836864
ids = append(ids, id)
837865
}
866+
if err := rows.Err(); err != nil {
867+
t.Fatalf("iterate steps: %v", err)
868+
}
838869
if len(ids) != 2 || ids[0] != stepID || ids[1] != step2ID {
839870
t.Errorf("got step order %v, want [%s, %s]", ids, stepID, step2ID)
840871
}
@@ -843,15 +874,27 @@ func TestV1Store_ExecutionStepLifecycle(t *testing.T) {
843874
func TestV1Store_ExecutionLogs(t *testing.T) {
844875
store := setupTestStore(t)
845876

846-
company, _ := store.CreateCompany("Co", "", "u1")
847-
org, _ := store.CreateOrganization(company.ID, "Org", "", "u1")
848-
proj, _ := store.CreateProject(org.ID, "Proj", "", "")
849-
wf, _ := store.CreateWorkflow(proj.ID, "WF", "", "", "modules: []", "u1")
877+
company, err := store.CreateCompany("Co", "", "u1")
878+
if err != nil {
879+
t.Fatalf("CreateCompany: %v", err)
880+
}
881+
org, err := store.CreateOrganization(company.ID, "Org", "", "u1")
882+
if err != nil {
883+
t.Fatalf("CreateOrganization: %v", err)
884+
}
885+
proj, err := store.CreateProject(org.ID, "Proj", "", "")
886+
if err != nil {
887+
t.Fatalf("CreateProject: %v", err)
888+
}
889+
wf, err := store.CreateWorkflow(proj.ID, "WF", "", "", "modules: []", "u1")
890+
if err != nil {
891+
t.Fatalf("CreateWorkflow: %v", err)
892+
}
850893

851894
now := time.Now().UTC()
852895

853896
// Insert logs at various levels
854-
err := store.InsertLog(wf.ID, "exec-1", "info", "Workflow started", "engine", "{}", now)
897+
err = store.InsertLog(wf.ID, "exec-1", "info", "Workflow started", "engine", "{}", now)
855898
if err != nil {
856899
t.Fatalf("InsertLog(info): %v", err)
857900
}
@@ -958,17 +1001,31 @@ func TestV1Store_PhaseCTablesExist(t *testing.T) {
9581001
func TestV1Store_ExecutionFailure(t *testing.T) {
9591002
store := setupTestStore(t)
9601003

961-
company, _ := store.CreateCompany("Co", "", "u1")
962-
org, _ := store.CreateOrganization(company.ID, "Org", "", "u1")
963-
proj, _ := store.CreateProject(org.ID, "Proj", "", "")
964-
wf, _ := store.CreateWorkflow(proj.ID, "WF", "", "", "modules: []", "u1")
1004+
company, err := store.CreateCompany("Co", "", "u1")
1005+
if err != nil {
1006+
t.Fatalf("CreateCompany: %v", err)
1007+
}
1008+
org, err := store.CreateOrganization(company.ID, "Org", "", "u1")
1009+
if err != nil {
1010+
t.Fatalf("CreateOrganization: %v", err)
1011+
}
1012+
proj, err := store.CreateProject(org.ID, "Proj", "", "")
1013+
if err != nil {
1014+
t.Fatalf("CreateProject: %v", err)
1015+
}
1016+
wf, err := store.CreateWorkflow(proj.ID, "WF", "", "", "modules: []", "u1")
1017+
if err != nil {
1018+
t.Fatalf("CreateWorkflow: %v", err)
1019+
}
9651020

9661021
now := time.Now().UTC()
9671022
execID := "exec-fail-001"
968-
_ = store.InsertExecution(execID, wf.ID, "manual", "running", "u1", now)
1023+
if err = store.InsertExecution(execID, wf.ID, "manual", "running", "u1", now); err != nil {
1024+
t.Fatalf("InsertExecution: %v", err)
1025+
}
9691026

9701027
// Fail the execution with an error message
971-
err := store.CompleteExecution(execID, "failed", now.Add(3*time.Second), 3000, "timeout exceeded")
1028+
err = store.CompleteExecution(execID, "failed", now.Add(3*time.Second), 3000, "timeout exceeded")
9721029
if err != nil {
9731030
t.Fatalf("CompleteExecution(failed): %v", err)
9741031
}
@@ -985,7 +1042,10 @@ func TestV1Store_ExecutionFailure(t *testing.T) {
9851042
t.Errorf("got error_message %q, want %q", errMsg, "timeout exceeded")
9861043
}
9871044

988-
counts, _ := store.CountExecutionsByWorkflow(wf.ID)
1045+
counts, err := store.CountExecutionsByWorkflow(wf.ID)
1046+
if err != nil {
1047+
t.Fatalf("CountExecutionsByWorkflow: %v", err)
1048+
}
9891049
if counts["failed"] != 1 {
9901050
t.Errorf("got failed count %d, want 1", counts["failed"])
9911051
}

0 commit comments

Comments
 (0)