Exemple #1
0
func TestSend(t *testing.T) {
	s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		if got, want := r.Header.Get("X-Api-Key"), "1234"; got != want {
			t.Fatal("API Key => %s; want %s", got, want)
		}

		w.WriteHeader(200)
	}))
	defer s.Close()

	c := NewClientFromKey("1234")
	c.URL = s.URL
	r := &Reporter{
		client: c,
	}

	if err := r.Report(context.Background(), reporter.NewError(errBoom, 0)); err != nil {
		t.Fatal(err)
	}
}
Exemple #2
0
	"io/ioutil"
	"net/http"
	"net/http/httptest"
	"path"
	"testing"

	"github.com/remind101/pkg/reporter"
	"golang.org/x/net/context"
)

var (
	// boom
	errBoom = errors.New("boom")

	// boom with backtrace.
	errBoomMore = reporter.NewError(errBoom, 0)
)

func TestSend(t *testing.T) {
	s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		if got, want := r.Header.Get("X-Api-Key"), "1234"; got != want {
			t.Fatal("API Key => %s; want %s", got, want)
		}

		w.WriteHeader(200)
	}))
	defer s.Close()

	c := NewClientFromKey("1234")
	c.URL = s.URL
	r := &Reporter{