Skip to content

Commit

Permalink
fix: loopvar issue
Browse files Browse the repository at this point in the history
  • Loading branch information
atzoum committed Sep 25, 2023
1 parent 68792e6 commit b80e5e1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 7 additions & 1 deletion backend-config/replay_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ func TestApplyReplayConfig(t *testing.T) {
},
Destinations: []DestinationT{
{
ID: "d-1",
ID: "d-1",
IsProcessorEnabled: true,
},
{
ID: "d-2",
IsProcessorEnabled: false,
},
},
},
Expand Down Expand Up @@ -56,6 +61,7 @@ func TestApplyReplayConfig(t *testing.T) {
require.Equal(t, map[string]interface{}{}, c.Sources[1].Config)
require.Len(t, c.Sources[1].Destinations, 1)
require.Equal(t, "er-d-1", c.Sources[1].Destinations[0].ID)
require.True(t, c.Sources[1].Destinations[0].IsProcessorEnabled)
})

t.Run("Invalid Replay Config", func(t *testing.T) {
Expand Down
9 changes: 6 additions & 3 deletions backend-config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,19 @@ type ConfigT struct {

func (c *ConfigT) SourcesMap() map[string]*SourceT {
sourcesMap := make(map[string]*SourceT)
for _, source := range c.Sources {
for i := range c.Sources {
source := c.Sources[i]
sourcesMap[source.ID] = &source
}
return sourcesMap
}

func (c *ConfigT) DestinationsMap() map[string]*DestinationT {
destinationsMap := make(map[string]*DestinationT)
for _, source := range c.Sources {
for _, destination := range source.Destinations {
for i := range c.Sources {
source := c.Sources[i]
for j := range source.Destinations {
destination := source.Destinations[j]
destinationsMap[destination.ID] = &destination
}
}
Expand Down

0 comments on commit b80e5e1

Please sign in to comment.