From 26e44c4bb052f4708e73ac2e7f6d472f2d3bbf7a Mon Sep 17 00:00:00 2001 From: Tochemey Date: Sat, 3 Aug 2024 22:53:58 +0100 Subject: [PATCH] refactor: rename localhost to 127.0.0.1 in tests --- README.md | 2 +- actors/api_test.go | 2 +- discovery/nats/discovery_test.go | 16 ++++++++-------- internal/cluster/codec_test.go | 2 +- internal/cluster/discovery_test.go | 2 +- internal/cluster/engine_test.go | 16 ++++++++-------- internal/http/http_test.go | 4 ++-- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 19453f18..13062563 100644 --- a/README.md +++ b/README.md @@ -516,7 +516,7 @@ package main import "github.com/tochemey/goakt/v2/discovery/nats" const ( - natsServerAddr = "nats://localhost:4248" + natsServerAddr = "nats://127.0.0.1:4248" natsSubject = "goakt-gossip" applicationName = "accounts" actorSystemName = "AccountsSystem" diff --git a/actors/api_test.go b/actors/api_test.go index 5b6f4199..aa9634ae 100644 --- a/actors/api_test.go +++ b/actors/api_test.go @@ -1820,7 +1820,7 @@ func TestAPIRemoteSpawn(t *testing.T) { // generate the remoting port ports := dynaport.Get(1) remotingPort := ports[0] - host := "localhost" + host := "127.0.0.1" // create the actor system sys, err := NewActorSystem("test", diff --git a/discovery/nats/discovery_test.go b/discovery/nats/discovery_test.go index f9ab1bab..49dc6ccd 100644 --- a/discovery/nats/discovery_test.go +++ b/discovery/nats/discovery_test.go @@ -70,7 +70,7 @@ func newPeer(t *testing.T, serverAddr string) *Discovery { remotingPort := nodePorts[2] // create a Cluster node - host := "localhost" + host := "127.0.0.1" // create the various config option applicationName := "accounts" actorSystemName := "AccountsSystem" @@ -114,7 +114,7 @@ func TestDiscovery(t *testing.T) { remotingPort := nodePorts[2] // create a Cluster node - host := "localhost" + host := "127.0.0.1" // create the various config option applicationName := "accounts" actorSystemName := "AccountsSystem" @@ -158,7 +158,7 @@ func TestDiscovery(t *testing.T) { remotingPort := nodePorts[2] // create a Cluster node - host := "localhost" + host := "127.0.0.1" // create the various config option applicationName := "accounts" actorSystemName := "AccountsSystem" @@ -195,7 +195,7 @@ func TestDiscovery(t *testing.T) { remotingPort := nodePorts[2] // create a Cluster node - host := "localhost" + host := "127.0.0.1" // create the various config option natsServer := srv.Addr().String() @@ -240,7 +240,7 @@ func TestDiscovery(t *testing.T) { remotingPort := nodePorts[2] // create a Cluster node - host := "localhost" + host := "127.0.0.1" // create the various config option natsServer := srv.Addr().String() @@ -280,7 +280,7 @@ func TestDiscovery(t *testing.T) { remotingPort := nodePorts[2] // create a Cluster node - host := "localhost" + host := "127.0.0.1" // create the various config option natsServer := srv.Addr().String() @@ -322,7 +322,7 @@ func TestDiscovery(t *testing.T) { remotingPort := nodePorts[2] // create a Cluster node - host := "localhost" + host := "127.0.0.1" // create the various config option natsServer := srv.Addr().String() @@ -423,7 +423,7 @@ func TestDiscovery(t *testing.T) { remotingPort := nodePorts[2] // create a Cluster node - host := "localhost" + host := "127.0.0.1" // create the various config option natsServer := srv.Addr().String() diff --git a/internal/cluster/codec_test.go b/internal/cluster/codec_test.go index a550c2ee..fd8cbc76 100644 --- a/internal/cluster/codec_test.go +++ b/internal/cluster/codec_test.go @@ -42,7 +42,7 @@ func TestCodec(t *testing.T) { actor := &internalpb.WireActor{ ActorName: "account-1", ActorAddress: &goaktpb.Address{ - Host: "localhost", + Host: "127.0.0.1", Port: 2345, Name: "account-1", Id: uuid.NewString(), diff --git a/internal/cluster/discovery_test.go b/internal/cluster/discovery_test.go index 58e8ecca..ef7a6a6d 100644 --- a/internal/cluster/discovery_test.go +++ b/internal/cluster/discovery_test.go @@ -221,7 +221,7 @@ func TestDiscoveryProvider(t *testing.T) { gossipPort := nodePorts[0] addrs := []string{ - fmt.Sprintf("localhost:%d", gossipPort), + fmt.Sprintf("127.0.0.1:%d", gossipPort), } // mock the underlying discovery provider provider := new(testkit.Provider) diff --git a/internal/cluster/engine_test.go b/internal/cluster/engine_test.go index 85fcdf2f..738a6840 100644 --- a/internal/cluster/engine_test.go +++ b/internal/cluster/engine_test.go @@ -61,7 +61,7 @@ func TestSingleNode(t *testing.T) { // define discovered addresses addrs := []string{ - fmt.Sprintf("localhost:%d", gossipPort), + fmt.Sprintf("127.0.0.1:%d", gossipPort), } // mock the discovery provider @@ -75,7 +75,7 @@ func TestSingleNode(t *testing.T) { provider.EXPECT().Close().Return(nil) // create a Node startNode - host := "localhost" + host := "127.0.0.1" hostNode := discovery.Node{ Name: host, @@ -117,7 +117,7 @@ func TestSingleNode(t *testing.T) { // define discovered addresses addrs := []string{ - fmt.Sprintf("localhost:%d", gossipPort), + fmt.Sprintf("127.0.0.1:%d", gossipPort), } // mock the discovery provider @@ -131,7 +131,7 @@ func TestSingleNode(t *testing.T) { provider.EXPECT().Close().Return(nil) // create a Node startNode - host := "localhost" + host := "127.0.0.1" hostNode := discovery.Node{ Name: host, Host: host, @@ -187,7 +187,7 @@ func TestSingleNode(t *testing.T) { // define discovered addresses addrs := []string{ - fmt.Sprintf("localhost:%d", gossipPort), + fmt.Sprintf("127.0.0.1:%d", gossipPort), } // mock the discovery provider @@ -201,7 +201,7 @@ func TestSingleNode(t *testing.T) { provider.EXPECT().Close().Return(nil) // create a Node startNode - host := "localhost" + host := "127.0.0.1" hostNode := discovery.Node{ Name: host, Host: host, @@ -254,7 +254,7 @@ func TestSingleNode(t *testing.T) { // define discovered addresses addrs := []string{ - fmt.Sprintf("localhost:%d", gossipPort), + fmt.Sprintf("127.0.0.1:%d", gossipPort), } // mock the discovery provider @@ -268,7 +268,7 @@ func TestSingleNode(t *testing.T) { provider.EXPECT().Close().Return(nil) // create a Node startNode - host := "localhost" + host := "127.0.0.1" hostNode := discovery.Node{ Name: host, Host: host, diff --git a/internal/http/http_test.go b/internal/http/http_test.go index b4ec88a6..d4477651 100644 --- a/internal/http/http_test.go +++ b/internal/http/http_test.go @@ -44,9 +44,9 @@ func TestClient(t *testing.T) { } func TestURL(t *testing.T) { - host := "localhost" + host := "127.0.0.1" port := 123 url := URL(host, port) - assert.Equal(t, "http://localhost:123", url) + assert.Equal(t, "http://127.0.0.1:123", url) }