-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #241 from goatherder/event_v2_client
Event v2 client
- Loading branch information
Showing
3 changed files
with
84 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package pagerduty | ||
|
||
import ( | ||
"net/http" | ||
"testing" | ||
) | ||
|
||
func TestEventV2_ManageEvent(t *testing.T) { | ||
setup() | ||
defer teardown() | ||
|
||
mux.HandleFunc("/v2/enqueue", func(w http.ResponseWriter, r *http.Request) { | ||
testMethod(t, r, "POST") | ||
w.Write([]byte(`{"status": "ok", "dedup_key": "yes", "message": "ok"}`)) | ||
}) | ||
var client = &Client{v2EventsAPIEndpoint: server.URL, apiEndpoint: server.URL, authToken: "foo", HTTPClient: defaultHTTPClient} | ||
evt := &V2Event{ | ||
RoutingKey: "abc123", | ||
} | ||
res, err := client.ManageEvent(evt) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
want := &V2EventResponse{ | ||
Status: "ok", | ||
DedupKey: "yes", | ||
Message: "ok", | ||
} | ||
testEqual(t, want, res) | ||
} |