Skip to content

Commit 50f6c95

Browse files
committed
reduced the use of 'localhost' in tests
1 parent 5fc31e3 commit 50f6c95

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

pkg/kafka/testdata/application-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
kafka:
2-
brokers: localhost:19092
2+
brokers: 127.0.0.1:19092
33
bindings:
44
default:
55
producer:

pkg/kafka/testdata/mock_broker.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func WithMockedBroker() test.Options {
5454
}),
5555
apptest.WithDynamicProperties(map[string]apptest.PropertyValuerFunc{
5656
"kafka.brokers": func(ctx context.Context) interface{} {
57-
return fmt.Sprintf("localhost:%d", cfg.Port)
57+
return fmt.Sprintf("127.0.0.1:%d", cfg.Port)
5858
},
5959
}),
6060
apptest.WithFxOptions(fx.Provide(func() *MockBroker {
@@ -80,7 +80,7 @@ type MockedBrokerConfig struct {
8080
}
8181

8282
func NewMockedBroker(t *testing.T, cfg *MockedBrokerConfig) *MockBroker {
83-
mock := sarama.NewMockBrokerAddr(t, 0, fmt.Sprintf(`localhost:%d`, cfg.Port))
83+
mock := sarama.NewMockBrokerAddr(t, 0, fmt.Sprintf(`127.0.0.1:%d`, cfg.Port))
8484
ret := &MockBroker{
8585
MockBroker: mock,
8686
t: t,

test/apptest/bootstrap_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ func SubTestAdditionalDI(di *webDI) test.GomegaSubTestFunc {
270270
func SubTestWebController(di *webDI) test.GomegaSubTestFunc {
271271
return func(ctx context.Context, t *testing.T, g *gomega.WithT) {
272272
port := di.Register.ServerPort()
273-
url := fmt.Sprintf("http://localhost:%d/test/api", port)
273+
url := fmt.Sprintf("http://127.0.0.1:%d/test/api", port)
274274
resp, e := http.DefaultClient.Get(url)
275275
g.Expect(e).To(gomega.Succeed(), "http client should be succeeded")
276276
g.Expect(resp).To(gomega.Not(gomega.BeNil()), "http response should not be nil ")

0 commit comments

Comments
 (0)