-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve gun targets in phttp component once before shooting.
- Loading branch information
Showing
14 changed files
with
602 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package example | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
|
||
"github.com/yandex/pandora/lib/testutil" | ||
) | ||
|
||
func TestImport(t *testing.T) { | ||
testutil.RunSuite(t, "Import Suite") | ||
} | ||
|
||
var _ = Describe("import", func() { | ||
It("not panics", func() { | ||
Expect(Import).NotTo(Panic()) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package phttp | ||
|
||
import ( | ||
"net" | ||
"strconv" | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
"github.com/spf13/afero" | ||
|
||
. "github.com/yandex/pandora/components/phttp" | ||
"github.com/yandex/pandora/lib/testutil" | ||
) | ||
|
||
func TestImport(t *testing.T) { | ||
testutil.RunSuite(t, "phttp Import Suite") | ||
} | ||
|
||
var _ = Describe("import", func() { | ||
It("not panics", func() { | ||
Expect(func() { | ||
Import(afero.NewOsFs()) | ||
}).NotTo(Panic()) | ||
}) | ||
}) | ||
|
||
var _ = Describe("preResolveTargetAddr", func() { | ||
It("host target", func() { | ||
conf := &ClientConfig{} | ||
conf.Dialer.DNSCache = true | ||
|
||
listener, err := net.ListenTCP("tcp6", nil) | ||
defer listener.Close() | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
port := strconv.Itoa(listener.Addr().(*net.TCPAddr).Port) | ||
target := "localhost:" + port | ||
expectedResolved := "[::1]:" + port | ||
|
||
err = preResolveTargetAddr(conf, &target) | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(conf.Dialer.DNSCache).To(BeFalse()) | ||
|
||
Expect(target).To(Equal(expectedResolved)) | ||
}) | ||
|
||
It("ip target", func() { | ||
conf := &ClientConfig{} | ||
conf.Dialer.DNSCache = true | ||
|
||
const addr = "127.0.0.1:80" | ||
target := addr | ||
err := preResolveTargetAddr(conf, &target) | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(conf.Dialer.DNSCache).To(BeFalse()) | ||
Expect(target).To(Equal(addr)) | ||
}) | ||
|
||
It("failed", func() { | ||
conf := &ClientConfig{} | ||
conf.Dialer.DNSCache = true | ||
|
||
const addr = "localhost:54321" | ||
target := addr | ||
err := preResolveTargetAddr(conf, &target) | ||
Expect(err).To(HaveOccurred()) | ||
Expect(conf.Dialer.DNSCache).To(BeTrue()) | ||
Expect(target).To(Equal(addr)) | ||
}) | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.