Skip to content

Commit

Permalink
Bypass eventChan consumer if using custom consumer for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sambigeara committed Oct 1, 2022
1 parent fd95499 commit e9c1348
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
20 changes: 11 additions & 9 deletions pkg/service/crdt.go
Original file line number Diff line number Diff line change
Expand Up @@ -1604,16 +1604,18 @@ func (r *DBListRepo) startSync(ctx context.Context, replayChan chan []EventLog,

// Push to all WalFiles
var flushAgg, wsPubAgg []EventLog
go func() {
for {
select {
case e := <-r.eventsChan:
wsPubAgg = merge(wsPubAgg, []EventLog{e})
case <-ctx.Done():
return
if !r.isTest {
go func() {
for {
select {
case e := <-r.eventsChan:
wsPubAgg = merge(wsPubAgg, []EventLog{e})
case <-ctx.Done():
return
}
}
}
}()
}()
}
wsPublishTicker := time.NewTicker(websocketPublishDuration)
go func() {
for {
Expand Down
3 changes: 3 additions & 0 deletions pkg/service/crdt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,7 @@ func TestCRDTProcessEvent(t *testing.T) {

func TestCRDTAllPermsMix(t *testing.T) {
repo, clearUp := setupRepo()
repo.isTest = true
repoUUID := uuid(1)
repo.uuid = repoUUID

Expand Down Expand Up @@ -694,6 +695,7 @@ func TestCRDTAllPermsMix(t *testing.T) {

func TestCRDTAllPermsMoves(t *testing.T) {
repo, clearUp := setupRepo()
repo.isTest = true
repoUUID := uuid(1)
repo.uuid = repoUUID

Expand Down Expand Up @@ -801,6 +803,7 @@ func TestCRDTAllPermsMoves(t *testing.T) {

func TestCRDTAllPermsDeletes(t *testing.T) {
repo, clearUp := setupRepo()
repo.isTest = true
repo.uuid = uuid(1)

exit := make(chan struct{})
Expand Down
2 changes: 2 additions & 0 deletions pkg/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ type DBListRepo struct {
finalFlushChan chan struct{}

hasSyncedRemotes bool

isTest bool
}

// NewDBListRepo returns a pointer to a new instance of DBListRepo
Expand Down

0 comments on commit e9c1348

Please sign in to comment.