Skip to content

feat: add workflow management and enrollment commands#37

Merged
rianjs merged 1 commit intomainfrom
feat/26-workflow-management-commands
Feb 1, 2026
Merged

feat: add workflow management and enrollment commands#37
rianjs merged 1 commit intomainfrom
feat/26-workflow-management-commands

Conversation

@rianjs
Copy link
Contributor

@rianjs rianjs commented Feb 1, 2026

Summary

Extend workflow API and CLI with CRUD operations and enrollment management.

API Layer (api/automation.go)

  • CreateWorkflow(data) - create a new workflow from JSON
  • UpdateWorkflow(id, data) - update an existing workflow
  • DeleteWorkflow(id) - delete a workflow by ID
  • EnrollInWorkflow(workflowId, objectId) - enroll an object in a workflow
  • ListWorkflowEnrollments(workflowId, opts) - list enrolled objects with pagination
  • WorkflowEnrollment and WorkflowEnrollmentList types

CLI Commands

  • hspt workflows create --file workflow.json - create workflow from JSON file
  • hspt workflows update <id> --file workflow.json - update existing workflow
  • hspt workflows delete <id> - delete a workflow
  • hspt workflows enroll <workflowId> --object-id <objectId> - enroll object in workflow
  • hspt workflows enrollments <workflowId> - list workflow enrollments

Tests

  • Comprehensive API tests in api/automation_test.go
  • Tests for Create, Update, Delete, Enroll, and ListEnrollments operations
  • Tests cover success cases, empty results, and validation errors

Test Plan

  • make build passes
  • make test passes
  • make lint passes
  • API tests cover all new operations

Closes #26

Extend workflow API and CLI commands:
- api/automation.go: CreateWorkflow, UpdateWorkflow, DeleteWorkflow
- api/automation.go: EnrollInWorkflow, ListWorkflowEnrollments
- api/automation_test.go: Comprehensive tests for all new methods
- internal/cmd/workflows: create, update, delete, enroll, enrollments commands

Commands support workflow CRUD operations and object enrollment management.

Closes #26
@rianjs
Copy link
Contributor Author

rianjs commented Feb 1, 2026

Test Coverage Assessment for TDD

I've analyzed the test coverage for the workflow management and enrollment commands. Here's my assessment:

API Layer: Adequate for TDD

The tests in api/automation_test.go cover all 7 new functions with appropriate patterns:

  • ListWorkflows: success + empty results
  • GetWorkflow: success + not found + empty ID validation
  • CreateWorkflow: success only
  • UpdateWorkflow: success + empty ID validation
  • DeleteWorkflow: success + empty ID validation
  • EnrollInWorkflow: success + empty workflow ID + empty object ID
  • ListWorkflowEnrollments: success + empty workflow ID + empty results

This matches the established patterns in crm_test.go and other API test files.

Potential Gaps (non-blocking)

  1. Missing error cases for mutating operations:

    • CreateWorkflow lacks a 400 Bad Request test (e.g., invalid workflow definition)
    • DeleteWorkflow lacks a not-found test (though GetWorkflow has one)
  2. No malformed response tests - none of the API methods test JSON parse error paths

  3. CLI layer has no tests - but this is consistent with the entire codebase (internal/cmd/* packages all show [no test files])

Verdict: Coverage is sufficient

For TDD purposes, the coverage is adequate. The API layer tests:

  • Verify correct HTTP methods and paths
  • Validate query parameters and request bodies
  • Parse response structures correctly
  • Test input validation (empty ID checks)
  • Cover pagination scenarios

The gaps noted are minor and don't block a TDD workflow - they could be addressed in a follow-up if desired. The CLI layer testing gap is an architectural decision that appears intentional across this project (thin CLI layer with logic concentrated in the testable API layer).

@rianjs rianjs merged commit 89bb627 into main Feb 1, 2026
3 checks passed
@rianjs rianjs deleted the feat/26-workflow-management-commands branch February 1, 2026 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Workflow management and enrollment commands

1 participant

Comments