mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-06 21:57:36 +03:00
make utils an internal package
This commit is contained in:
parent
24d9ed2769
commit
c0b09c8646
74 changed files with 51 additions and 52 deletions
49
internal/utils/host_test.go
Normal file
49
internal/utils/host_test.go
Normal file
|
@ -0,0 +1,49 @@
|
|||
package utils
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = Describe("Hostname", func() {
|
||||
It("gets the hostname from an URL", func() {
|
||||
h, err := HostnameFromAddr("https://quic.clemente.io/file.dat?param=true¶m2=false")
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(h).To(Equal("quic.clemente.io"))
|
||||
})
|
||||
|
||||
It("gets the hostname from an URL with a port number", func() {
|
||||
h, err := HostnameFromAddr("https://quic.clemente.io:6121/file.dat")
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(h).To(Equal("quic.clemente.io"))
|
||||
})
|
||||
|
||||
It("gets the hostname from an URL containing username and password", func() {
|
||||
h, err := HostnameFromAddr("https://user:password@quic.clemente.io:6121/file.dat")
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(h).To(Equal("quic.clemente.io"))
|
||||
})
|
||||
|
||||
It("gets local hostnames", func() {
|
||||
h, err := HostnameFromAddr("https://localhost/file.dat")
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(h).To(Equal("localhost"))
|
||||
})
|
||||
|
||||
It("gets the hostname for other protocols", func() {
|
||||
h, err := HostnameFromAddr("ftp://quic.clemente.io:6121/file.dat")
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(h).To(Equal("quic.clemente.io"))
|
||||
})
|
||||
|
||||
It("gets an IP", func() {
|
||||
h, err := HostnameFromAddr("https://1.3.3.7:6121/file.dat")
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(h).To(Equal("1.3.3.7"))
|
||||
})
|
||||
|
||||
It("errors on malformed URLs", func() {
|
||||
_, err := HostnameFromAddr("://quic.clemente.io:6121/file.dat")
|
||||
Expect(err).To(HaveOccurred())
|
||||
})
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue