diff --git a/zeropod/port_test.go b/zeropod/port_test.go index 7655d8d..f91f23c 100644 --- a/zeropod/port_test.go +++ b/zeropod/port_test.go @@ -1,24 +1,34 @@ package zeropod import ( + "net/http/httptest" + "net/url" + "os" + "strconv" "testing" -) - -// func TestListeningPorts(t *testing.T) { -// ts := httptest.NewServer(nil) + "time" -// ports, err := ListeningPorts(os.Getpid()) -// require.NoError(t, err) + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) -// u, err := url.Parse(ts.URL) -// require.NoError(t, err) +func TestListeningPorts(t *testing.T) { + ts := httptest.NewServer(nil) + ts2 := httptest.NewServer(nil) + ports, err := listeningPortsDeep(os.Getpid()) + require.NoError(t, err) -// port, err := strconv.ParseUint(u.Port(), 10, 16) -// require.NoError(t, err) + u, err := url.Parse(ts.URL) + require.NoError(t, err) + u2, err := url.Parse(ts2.URL) + require.NoError(t, err) -// assert.Contains(t, ports, uint16(port)) -// } + port, err := strconv.Atoi(u.Port()) + require.NoError(t, err) + port2, err := strconv.Atoi(u2.Port()) + require.NoError(t, err) + assert.Contains(t, ports, uint16(port)) + assert.Contains(t, ports, uint16(port2)) -func TestInodes(t *testing.T) { - inodes(14819) + time.Sleep(time.Minute) }