Skip to content

Commit

Permalink
update handler function and write unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MahtabBukhari committed Nov 19, 2024
1 parent 3aeb685 commit 0638d6e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions handlers/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func (wh *workflowHandler) HandleWorkflowRequest(w http.ResponseWriter, r *http.
}

request.Status = db.StatusNew
request.RequestID = processedRequestID

if err := wh.db.CreateWorkflowRequest(&request); err != nil {
http.Error(w, "Failed to create workflow request", http.StatusInternalServerError)
Expand Down
13 changes: 10 additions & 3 deletions handlers/workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,18 @@ func TestHandleWorkflowRequest(t *testing.T) {
wh := NewWorkFlowHandler(db.TestDB)

t.Run("successful workflow request", func(t *testing.T) {
requestData := db.PropertyMap{
"test_key": "test_value",
}

request := db.WfRequest{
WorkflowID: uuid.New().String(),
Source: "test_source",
RequestID: uuid.New().String(),
Source: "test_source",
Action: "test_action",
WorkflowID: "workflow_id",
ProjectID: uuid.New().String(),
RequestData: requestData,
}

body, _ := json.Marshal(request)

req := httptest.NewRequest(http.MethodPost, "/workflows/request", bytes.NewBuffer(body))
Expand Down

0 comments on commit 0638d6e

Please sign in to comment.