fix(query): realtime data on defined requests (#3726)

* feat: directly specify factors on addCustomLoginPolicy and return on LoginPolicy responses

* fix proto

* update login policy

* feat: directly specify idp on addCustomLoginPolicy and return on LoginPolicy responses

* fix: tests

* fix(projection): trigger bulk

* refactor: clean projection pkg

* instance should bulk

* fix(query): should trigger bulk on id calls

* tests

* build prerelease

* fix: add shouldTriggerBulk

* fix: test

Co-authored-by: Livio Amstutz <[email protected]>
Co-authored-by: Max Peintner <[email protected]>
This commit is contained in:
Silvan
2022-06-14 07:51:00 +02:00
committed by GitHub
co-authored by Livio Amstutz Max Peintner
parent 5c805c48db
commit dd2f31683c
146 changed files with 1097 additions and 1239 deletions
@@ -8,6 +8,7 @@ import (
"testing"
"time"
"github.com/golang/mock/gomock"
"github.com/zitadel/zitadel/internal/eventstore"
"github.com/zitadel/zitadel/internal/eventstore/repository"
es_repo_mock "github.com/zitadel/zitadel/internal/eventstore/repository/mock"
@@ -126,7 +127,11 @@ func TestProjectionHandler_processEvent(t *testing.T) {
},
ProjectionName: "",
RequeueEvery: -1,
})
},
nil,
nil,
nil,
)
h.stmts = tt.fields.stmts
h.pushSet = tt.fields.pushSet
h.shouldPush = tt.fields.shouldPush
@@ -408,7 +413,11 @@ func TestProjectionHandler_push(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
h := NewProjectionHandler(ProjectionHandlerConfig{
HandlerConfig: HandlerConfig{},
})
},
nil,
nil,
nil,
)
h.stmts = tt.fields.stmts
h.pushSet = tt.fields.pushSet
if tt.args.previousLock > 0 {
@@ -655,8 +664,13 @@ func TestProjectionHandler_bulk(t *testing.T) {
HandlerConfig: HandlerConfig{},
ProjectionName: "",
RequeueEvery: -1,
})
err := h.bulk(tt.args.ctx, tt.args.lock.lock(), tt.args.executeBulk.executeBulk(), tt.args.unlock.unlock())
},
tt.args.executeBulk.Reduce,
tt.args.executeBulk.Update,
tt.args.executeBulk.Query,
)
h.Eventstore = tt.args.executeBulk.es(t)
err := h.bulk(tt.args.ctx, tt.args.lock.lock(), tt.args.unlock.unlock())
if !tt.res.isErr(err) {
t.Errorf("unexpected error %v", err)
}
@@ -873,6 +887,26 @@ type executeBulkMock struct {
canceled chan bool
}
func (m *executeBulkMock) Query(context.Context) (*eventstore.SearchQueryBuilder, uint64, error) {
m.callCount++
if m.err != nil {
return nil, 0, m.err
}
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent).AddQuery().SequenceGreater(0).Builder(), 0, nil
}
func (m *executeBulkMock) Reduce(eventstore.Event) (*Statement, error) {
return nil, nil
}
func (m *executeBulkMock) Update(ctx context.Context, stmts []*Statement, reduce Reduce) (unexecutedStmts []*Statement, err error) {
return nil, nil
}
func (m *executeBulkMock) es(t *testing.T) *eventstore.Eventstore {
mock := es_repo_mock.NewRepo(t)
mock.EXPECT().Filter(gomock.Any(), gomock.Any()).AnyTimes().Return(nil, nil)
return eventstore.NewEventstore(mock)
}
func (m *executeBulkMock) executeBulk() executeBulk {
return func(ctx context.Context) error {
m.callCount++