1package localip_test
2
3import (
4	"net"
5
6	"code.cloudfoundry.org/localip"
7
8	. "github.com/onsi/ginkgo"
9	. "github.com/onsi/gomega"
10)
11
12var _ = Describe("Localip", func() {
13	Describe("LocalIP", func() {
14		It("returns a local IP", func() {
15			ip, err := localip.LocalIP()
16			Expect(err).NotTo(HaveOccurred())
17
18			// http://golang.org/pkg/net/#ParseIP
19			// If s is not a valid textual representation of an IP address, ParseIP returns nil.
20			Expect(net.ParseIP(ip)).NotTo(BeNil())
21		})
22	})
23
24	Describe("LocalPort", func() {
25		It("returns a local port", func() {
26			port, err := localip.LocalPort()
27			Expect(err).NotTo(HaveOccurred())
28			Expect(port).To(BeNumerically(">", 0))
29		})
30	})
31})
32