diff --git a/logtail/logtail_test.go b/logtail/logtail_test.go index 5f435a8cd..5e3083cc3 100644 --- a/logtail/logtail_test.go +++ b/logtail/logtail_test.go @@ -6,6 +6,8 @@ package logtail import ( "context" + "net/http" + "net/http/httptest" "testing" "time" ) @@ -20,6 +22,27 @@ func TestFastShutdown(t *testing.T) { l.Shutdown(ctx) } +func TestUploadMessages(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + uploads := 0 + testServ := httptest.NewServer(http.HandlerFunc( + func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json; charset=utf-8") + uploads += 1 + })) + + l := NewLogger(Config{BaseURL: testServ.URL}, t.Logf) + for i := 1; i < 10; i++ { + l.Write([]byte("log line")) + } + + l.Shutdown(ctx) + cancel() + if uploads == 0 { + t.Error("no log uploads") + } +} + var sink []byte func TestLoggerEncodeTextAllocs(t *testing.T) {