| 1 | package slack |
| 2 | |
| 3 | import ( |
| 4 | "encoding/json" |
| 5 | "net/http" |
| 6 | "testing" |
| 7 | ) |
| 8 | |
| 9 | func workflowStepHandler(rw http.ResponseWriter, r *http.Request) { |
| 10 | rw.Header().Set("Content-Type", "application/json") |
| 11 | response, _ := json.Marshal(SlackResponse{ |
| 12 | Ok: true, |
| 13 | }) |
| 14 | rw.Write(response) |
| 15 | } |
| 16 | |
| 17 | func TestWorkflowStepCompleted(t *testing.T) { |
| 18 | http.HandleFunc("/workflows.stepCompleted", workflowStepHandler) |
| 19 | once.Do(startServer) |
| 20 | api := New("testing-token", OptionAPIURL("http://"+serverAddr+"/")) |
| 21 | |
| 22 | if err := api.WorkflowStepCompleted("executeID"); err != nil { |
| 23 | t.Errorf("Unexpected error: %s", err) |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | func TestWorkflowStepFailed(t *testing.T) { |
| 28 | http.HandleFunc("/workflows.stepFailed", workflowStepHandler) |
| 29 | once.Do(startServer) |
| 30 | api := New("testing-token", OptionAPIURL("http://"+serverAddr+"/")) |
| 31 | |
| 32 | if err := api.WorkflowStepFailed("executeID", "error message"); err != nil { |
| 33 | t.Errorf("Unexpected error: %s", err) |
| 34 | } |
| 35 | } |