From 9f5b76239553cb9bcd3e0103cfbaa46b8f40a082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20SZKIBA?= Date: Thu, 17 Aug 2023 12:58:35 +0200 Subject: [PATCH] test: use port number 0 for an unuse dport --- dashboard/extension_test.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/dashboard/extension_test.go b/dashboard/extension_test.go index 0cdfb94..532fc35 100644 --- a/dashboard/extension_test.go +++ b/dashboard/extension_test.go @@ -7,7 +7,6 @@ package dashboard import ( "embed" "fmt" - "net" "os" "strconv" "strings" @@ -46,13 +45,10 @@ func TestNewExtension(t *testing.T) { func TestExtension(t *testing.T) { t.Parallel() - port := getRandomPort(t) - addr := net.JoinHostPort("127.0.0.1", strconv.Itoa(port)) - var params output.Params params.Logger = logrus.StandardLogger() - params.ConfigArgument = "period=10ms&port=" + strconv.Itoa(port) + params.ConfigArgument = "period=10ms&port=0" ext, err := New(params, embed.FS{}, embed.FS{}) @@ -69,7 +65,7 @@ func TestExtension(t *testing.T) { ext.AddMetricSamples(testSampleContainer(t, sample).toArray()) }() - lines := readSSE(t, 7, "http://"+addr+"/events") + lines := readSSE(t, 7, "http://"+ext.options.addr()+"/events") assert.NotNil(t, lines) assert.Equal(t, "event: snapshot", lines[2])