Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ go 1.18

require (
github.com/bits-and-blooms/bloom/v3 v3.3.1
github.com/splitio/go-toolkit/v5 v5.4.0
github.com/stretchr/testify v1.9.0
github.com/splitio/go-toolkit/v5 v5.4.1-0.20250930172659-38274b802d99
github.com/stretchr/testify v1.11.1
golang.org/x/sync v0.3.0
gopkg.in/yaml.v3 v3.0.1
)
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/redis/go-redis/v9 v9.0.4 h1:FC82T+CHJ/Q/PdyLW++GeCO+Ol59Y4T7R4jbgjvktgc=
github.com/redis/go-redis/v9 v9.0.4/go.mod h1:WqMKv5vnQbRuZstUwxQI195wHy+t4PuXDOjzMvcuQHk=
github.com/splitio/go-toolkit/v5 v5.4.0 h1:g5WFpRhQomnXCmvfsNOWV4s5AuUrWIZ+amM68G8NBKM=
github.com/splitio/go-toolkit/v5 v5.4.0/go.mod h1:xYhUvV1gga9/1029Wbp5pjnR6Cy8nvBpjw99wAbsMko=
github.com/splitio/go-toolkit/v5 v5.4.1-0.20250930172659-38274b802d99 h1:rQo355F9JbdyTMz2X5MU+FeRvkT6rvD1n+GnXdJr33A=
github.com/splitio/go-toolkit/v5 v5.4.1-0.20250930172659-38274b802d99/go.mod h1:SifzysrOVDbzMcOE8zjX02+FG5az4FrR3Us/i5SeStw=
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/twmb/murmur3 v1.1.6 h1:mqrRot1BRxm+Yct+vavLMou2/iJt0tNVTTC0QoIjaZg=
github.com/twmb/murmur3 v1.1.6/go.mod h1:Qq/R7NUyOfr65zD+6Q5IHKsJLwP7exErjN6lyyq3OSQ=
golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
Expand Down
23 changes: 23 additions & 0 deletions healthcheck/mocks/applicationmonitor.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package mocks

import (
"github.com/splitio/go-split-commons/v7/healthcheck/application"

"github.com/stretchr/testify/mock"
)

// MockApplicationMonitor mocked implementation of application monitor
type MockApplicationMonitor struct {
NotifyEventCall func(counterType int)
Expand All @@ -15,3 +21,20 @@ func (m MockApplicationMonitor) NotifyEvent(counterType int) {
func (m MockApplicationMonitor) Reset(counterType int, value int) {
m.ResetCall(counterType, value)
}

// ApplicationMonitorMock is a mock for the ApplicationMonitor interface
type ApplicationMonitorMock struct {
mock.Mock
}

// NotifyEvent mock
func (m *ApplicationMonitorMock) NotifyEvent(counterType int) {
m.Called(counterType)
}

// Reset mock
func (m *ApplicationMonitorMock) Reset(counterType int, value int) {
m.Called(counterType, value)
}

var _ application.MonitorProducerInterface = (*MockApplicationMonitor)(nil)
2 changes: 1 addition & 1 deletion service/api/specs/splitversionfilter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestParseAndValidate(t *testing.T) {
}
}

func TestsplitVersionFilter(t *testing.T) {
func TestSplitVersionFilter(t *testing.T) {
filter := NewSplitVersionFilter()
shouldFilter := filter.ShouldFilter(grammar.MatcherTypeBetweenSemver, FLAG_V1_0)
if !shouldFilter {
Expand Down
14 changes: 11 additions & 3 deletions service/mocks/split.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,22 @@ package mocks
import (
"github.com/splitio/go-split-commons/v7/dtos"
"github.com/splitio/go-split-commons/v7/service"

"github.com/stretchr/testify/mock"
)

// MockSplitFetcher mocked implementation of split fetcher
type MockSplitFetcher struct {
FetchCall func(fetchOptions *service.FlagRequestParams) (*dtos.SplitChangesDTO, error)
mock.Mock
}

// Fetch mock
func (m MockSplitFetcher) Fetch(fetchOptions *service.FlagRequestParams) (*dtos.SplitChangesDTO, error) {
return m.FetchCall(fetchOptions)
func (m *MockSplitFetcher) Fetch(fetchOptions *service.FlagRequestParams) (*dtos.SplitChangesDTO, error) {
args := m.Called(fetchOptions)
if args.Get(0) == nil {
return nil, args.Error(1)
}
return args.Get(0).(*dtos.SplitChangesDTO), args.Error(1)
}

var _ service.SplitFetcher = (*MockSplitFetcher)(nil)
2 changes: 1 addition & 1 deletion storage/mocks/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (m MockEventStorage) Push(event dtos.EventDTO, size int) error {

// Drop mock
func (m MockEventStorage) Drop(size *int64) error {
return m.Drop(size)
return m.DropCall(size)
}

// PopNRaw mock
Expand Down
2 changes: 1 addition & 1 deletion storage/mocks/impression.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (m MockImpressionStorage) PopNWithMetadata(n int64) ([]dtos.ImpressionQueue

// Drop mock
func (m MockImpressionStorage) Drop(size *int64) error {
return m.Drop(size)
return m.DropCall(size)
}

// PopNRaw mock
Expand Down
8 changes: 3 additions & 5 deletions storage/mocks/rulebasedsegment.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type MockRuleBasedSegmentStorage struct {
// ChangeNumber mock
func (m *MockRuleBasedSegmentStorage) ChangeNumber() int64 {
args := m.Called()
return int64(args.Int(0))
return args.Get(0).(int64)
}

// All mock
Expand Down Expand Up @@ -56,20 +56,18 @@ func (m *MockRuleBasedSegmentStorage) GetRuleBasedSegmentByName(name string) (*d

// SetChangeNumber mock
func (m *MockRuleBasedSegmentStorage) SetChangeNumber(till int64) error {
m.Called(till)
return nil
args := m.Called(till)
return args.Error(0)
}

// Update mock
func (m *MockRuleBasedSegmentStorage) Update(toAdd []dtos.RuleBasedSegmentDTO, toRemove []dtos.RuleBasedSegmentDTO, till int64) {
m.Called(toAdd, toRemove, till)
return
}

// Clear mock
func (m *MockRuleBasedSegmentStorage) Clear() {
m.Called()
return
}

var _ storage.RuleBasedSegmentsStorage = (*MockRuleBasedSegmentStorage)(nil)
116 changes: 116 additions & 0 deletions storage/mocks/split.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package mocks

import (
"github.com/splitio/go-split-commons/v7/dtos"
"github.com/splitio/go-split-commons/v7/storage"
"github.com/splitio/go-toolkit/v5/datastructures/set"
"github.com/stretchr/testify/mock"
)

// MockSplitStorage is a mocked implementation of Split Storage
Expand Down Expand Up @@ -96,3 +98,117 @@ func (m MockSplitStorage) GetAllFlagSetNames() []string {
func (m MockSplitStorage) ReplaceAll(toAdd []dtos.SplitDTO, changeNumber int64) {
m.ReplaceAllCall(toAdd, changeNumber)
}

// SplitStorageMock is a mocked implementation of Split Storage with testify
type SplitStorageMock struct {
mock.Mock
}

// All mock
func (m *SplitStorageMock) All() []dtos.SplitDTO {
args := m.Called()
return args.Get(0).([]dtos.SplitDTO)
}

// ChangeNumber mock
func (m *SplitStorageMock) ChangeNumber() (int64, error) {
args := m.Called()
return args.Get(0).(int64), args.Error(1)
}

// FetchMany mock
func (m *SplitStorageMock) FetchMany(splitNames []string) map[string]*dtos.SplitDTO {
args := m.Called(splitNames)
if args.Get(0) == nil {
return nil
}
return args.Get(0).(map[string]*dtos.SplitDTO)
}

// KillLocally mock
func (m *SplitStorageMock) KillLocally(splitName string, defaultTreatment string, changeNumber int64) {
m.Called(splitName, defaultTreatment, changeNumber)
}

// Update mock
func (m *SplitStorageMock) Update(toAdd []dtos.SplitDTO, toRemove []dtos.SplitDTO, changeNumber int64) {
m.Called(toAdd, toRemove, changeNumber)
}

// Remove mock
func (m *SplitStorageMock) Remove(splitname string) {
m.Called(splitname)
}

// SegmentNames mock
func (m *SplitStorageMock) SegmentNames() *set.ThreadUnsafeSet {
args := m.Called()
if args.Get(0) == nil {
return nil
}
return args.Get(0).(*set.ThreadUnsafeSet)
}

// LargeSegmentNames mock
func (m *SplitStorageMock) LargeSegmentNames() *set.ThreadUnsafeSet {
args := m.Called()
if args.Get(0) == nil {
return nil
}
return args.Get(0).(*set.ThreadUnsafeSet)
}

// SetChangeNumber mock
func (m *SplitStorageMock) SetChangeNumber(changeNumber int64) error {
args := m.Called(changeNumber)
return args.Error(0)
}

// Split mock
func (m *SplitStorageMock) Split(splitName string) *dtos.SplitDTO {
args := m.Called(splitName)
if args.Get(0) == nil {
return nil
}
return args.Get(0).(*dtos.SplitDTO)
}

// SplitNames mock
func (m *SplitStorageMock) SplitNames() []string {
args := m.Called()
if args.Get(0) == nil {
return nil
}
return args.Get(0).([]string)
}

// TrafficTypeExists mock
func (m *SplitStorageMock) TrafficTypeExists(trafficType string) bool {
args := m.Called(trafficType)
return args.Bool(0)
}

// GetNamesByFLagSets mock
func (m *SplitStorageMock) GetNamesByFlagSets(sets []string) map[string][]string {
args := m.Called(sets)
if args.Get(0) == nil {
return nil
}
return args.Get(0).(map[string][]string)
}

// GetAllFlagSetNames mock
func (m *SplitStorageMock) GetAllFlagSetNames() []string {
args := m.Called()
if args.Get(0) == nil {
return nil
}
return args.Get(0).([]string)
}

// ReplaceAll mock
func (m *SplitStorageMock) ReplaceAll(toAdd []dtos.SplitDTO, changeNumber int64) {
m.Called(toAdd, changeNumber)
}

var _ storage.SplitStorage = (*SplitStorageMock)(nil)
Loading
Loading