mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-17 23:56:56 +00:00
GODT-35: New pmapi client and manager using resty
This commit is contained in:
@ -18,8 +18,10 @@
|
||||
package pmapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@ -28,15 +30,20 @@ const testSendSimpleMetricsBody = `{
|
||||
}
|
||||
`
|
||||
|
||||
func TestClient_SendSimpleMetric(t *testing.T) {
|
||||
s, c := newTestServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
// FIXME(conman): Implement metrics then enable this test.
|
||||
func _TestClient_SendSimpleMetric(t *testing.T) {
|
||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
Ok(t, checkMethodAndPath(r, "GET", "/metrics?Action=some_action&Category=some_category&Label=some_label"))
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
fmt.Fprint(w, testSendSimpleMetricsBody)
|
||||
}))
|
||||
defer s.Close()
|
||||
|
||||
err := c.SendSimpleMetric("some_category", "some_action", "some_label")
|
||||
m := newManager(Config{HostURL: s.URL})
|
||||
|
||||
err := m.SendSimpleMetric(context.TODO(), "some_category", "some_action", "some_label")
|
||||
if err != nil {
|
||||
t.Fatal("Expected no error while sending simple metric, got:", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user