Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions internal/extproc/watcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"os"
"strings"
"sync"
"sync/atomic"
"testing"
"time"

Expand All @@ -26,15 +27,15 @@ import (
type mockReceiver struct {
cfg *filterapi.Config
mux sync.Mutex
loadCount int
loadCount atomic.Int32
}

// LoadConfig implements ConfigReceiver.
func (m *mockReceiver) LoadConfig(_ context.Context, cfg *filterapi.Config) error {
m.mux.Lock()
defer m.mux.Unlock()
m.cfg = cfg
m.loadCount++
m.loadCount.Add(1)
return nil
}

Expand Down Expand Up @@ -99,7 +100,7 @@ func TestStartConfigWatcher(t *testing.T) {

// Wait for a couple ticks to verify default config is not reloaded.
time.Sleep(2 * tickInterval)
require.Equal(t, 1, rcv.loadCount)
require.Equal(t, int32(1), rcv.loadCount.Load())

// Create the initial config file.
cfg := `
Expand Down Expand Up @@ -173,7 +174,7 @@ rules:

// Wait for a couple ticks to verify config is not reloaded if file does not change.
time.Sleep(2 * tickInterval)
require.Equal(t, 3, rcv.loadCount)
require.Equal(t, int32(3), rcv.loadCount.Load())
}

func TestDiff(t *testing.T) {
Expand Down