logtail: start a local server for TestFastShutdown

Right now TestFastShutdown tries to upload logs to localhost:1234,
which will most likely respond with an error. However if one has an
actual service running on port 1234, it would receive a connection
attempting to POST every time the unit test runs.

Start a local server and direct the upload there instead.

Signed-off-by: Denton Gentry <dgentry@tailscale.com>
pull/1112/head
Denton Gentry 4 years ago committed by Denton Gentry
parent 2e9728023b
commit b771a1363b

@ -16,8 +16,12 @@ func TestFastShutdown(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
cancel()
testServ := httptest.NewServer(http.HandlerFunc(
func(w http.ResponseWriter, r *http.Request) {}))
defer testServ.Close()
l := NewLogger(Config{
BaseURL: "http://localhost:1234",
BaseURL: testServ.URL,
}, t.Logf)
l.Shutdown(ctx)
}
@ -30,6 +34,7 @@ func TestUploadMessages(t *testing.T) {
w.Header().Set("Content-Type", "application/json; charset=utf-8")
uploads += 1
}))
defer testServ.Close()
l := NewLogger(Config{BaseURL: testServ.URL}, t.Logf)
for i := 1; i < 10; i++ {

Loading…
Cancel
Save