INNER CODE UNIT · Go

TestClient_PublishEvents_ShouldPostEventsToIngestionAPI

samsara/samsara · clients/go/client_test.go:119

func TestClient_PublishEvents_ShouldPostEventsToIngestionAPI(t *testing.T) {
	mockServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		payload, err := ioutil.ReadAll(r.Body)
		if payload == nil || err != nil {
			t.Errorf("Data should have been sent. Got error: %+v", err)
		}
	}))
	defer mockServer.Close()

	config := NewConfig()
	config.Url = mockServer.URL
	client, _ := NewClient(config)

	data := []Event{
		{
			"eventName": "foo",
			"sourceId":  "baz",
			"timestamp": 123,

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…