-
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.
Merge pull request #70 from yandex/feature/40
Support NewFactory constructors in plugin pkg. Target address pre resolve as bonus.
- Loading branch information
Showing
27 changed files
with
1,965 additions
and
609 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
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("tcp4", nil) | ||
defer listener.Close() | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
port := strconv.Itoa(listener.Addr().(*net.TCPAddr).Port) | ||
target := "localhost:" + port | ||
expectedResolved := "127.0.0.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
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
Oops, something went wrong.