Skip to content

Commit

Permalink
fix: initialize bandit reward mutex at tests
Browse files Browse the repository at this point in the history
  • Loading branch information
WendelHime committed Nov 27, 2024
1 parent 72a77d4 commit 2558a9e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions dialer/bandit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"path/filepath"
"reflect"
"strings"
"sync"
"testing"
"time"

Expand Down Expand Up @@ -324,14 +325,14 @@ func Test_differentArm(t *testing.T) {
}
}

func TestSaveBanditRewards(t *testing.T) {
func TestUpdateBanditRewards(t *testing.T) {
var tests = []struct {
name string
given map[string]banditMetrics
assert func(t *testing.T, dir string, err error)
}{
{
name: "it should save the rewards",
name: "it should update rewards file",
given: map[string]banditMetrics{
"test-dialer": {
Reward: 1.0,
Expand Down Expand Up @@ -364,6 +365,7 @@ func TestSaveBanditRewards(t *testing.T) {
opts: &Options{
BanditDir: tempDir,
},
banditRewardsMutex: new(sync.Mutex),
}
err = banditDialer.UpdateBanditRewards(tt.given)
tt.assert(t, tempDir, err)
Expand Down Expand Up @@ -405,6 +407,7 @@ func TestLoadLastBanditRewards(t *testing.T) {
opts: &Options{
BanditDir: tempDir,
},
banditRewardsMutex: new(sync.Mutex),
}
metrics, err := banditDialer.LoadLastBanditRewards()
tt.assert(t, metrics, err)
Expand Down

0 comments on commit 2558a9e

Please sign in to comment.