Skip to content

Commit

Permalink
Remove unused indexByAlias() function
Browse files Browse the repository at this point in the history
  • Loading branch information
roivaz committed Jul 26, 2023
1 parent b919e81 commit a4ff688
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 45 deletions.
11 changes: 0 additions & 11 deletions pkg/redis/server/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,6 @@ func (pool *ServerPool) GetServer(connectionString string, alias *string) (*Serv
return srv, nil
}

func (pool *ServerPool) indexByAlias() map[string]*Server {
index := make(map[string]*Server, len(pool.servers))
for _, srv := range pool.servers {
if srv.alias != "" {
index[srv.alias] = srv
}
}

return index
}

func (pool *ServerPool) indexByHostPort() map[string]*Server {
index := make(map[string]*Server, len(pool.servers))
for _, srv := range pool.servers {
Expand Down
34 changes: 0 additions & 34 deletions pkg/redis/server/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,40 +88,6 @@ func TestServerPool_GetServer(t *testing.T) {
})
}

func TestServerPool_indexByAlias(t *testing.T) {
type fields struct {
servers []*Server
}
tests := []struct {
name string
fields fields
want map[string]*Server
}{
{
name: "Returns a map indexed by host",
fields: fields{
servers: []*Server{
{alias: "host1", client: nil, host: "127.0.0.1", port: "1000"},
{alias: "host2", client: nil, host: "127.0.0.2", port: "2000"},
},
},
want: map[string]*Server{
"host1": {alias: "host1", client: nil, host: "127.0.0.1", port: "1000"},
"host2": {alias: "host2", client: nil, host: "127.0.0.2", port: "2000"},
},
}}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
pool := &ServerPool{
servers: tt.fields.servers,
}
if got := pool.indexByAlias(); !reflect.DeepEqual(got, tt.want) {
t.Errorf("ServerPool.indexByAlias() = %v, want %v", got, tt.want)
}
})
}
}

func TestServerPool_indexByHost(t *testing.T) {
type fields struct {
servers []*Server
Expand Down

0 comments on commit a4ff688

Please sign in to comment.