Skip to content

Commit

Permalink
test: use port number 0 for an unuse dport
Browse files Browse the repository at this point in the history
  • Loading branch information
szkiba committed Aug 17, 2023
1 parent 83e9537 commit 9f5b762
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions dashboard/extension_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package dashboard
import (
"embed"
"fmt"
"net"
"os"
"strconv"
"strings"
Expand Down Expand Up @@ -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{})

Expand All @@ -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])
Expand Down

0 comments on commit 9f5b762

Please sign in to comment.