mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 11:04:25 +00:00
a43e1fc34a
* feat: change failed events to new projection * feat: change failed events to new projection * feat: change current sequences to new projection * feat: add tests * Update internal/api/grpc/admin/failed_event.go Co-authored-by: Livio Amstutz <livio.a@gmail.com> * Update internal/api/grpc/admin/view.go Co-authored-by: Livio Amstutz <livio.a@gmail.com> * fix: truncate * fix reset * fix reset * Rename V1.102__queries.sql to V1.103__queries.sql * improve current_sequence and truncate view tables * check sub tables of view are tables * Update internal/query/current_sequence_test.go Co-authored-by: Silvan <silvan.reusser@gmail.com> * fixes and use squirrel * missing error handling * lock before reset Co-authored-by: Livio Amstutz <livio.a@gmail.com> Co-authored-by: Silvan <silvan.reusser@gmail.com>
96 lines
1.9 KiB
Go
96 lines
1.9 KiB
Go
package admin_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
admin_grpc "github.com/caos/zitadel/internal/api/grpc/admin"
|
|
"github.com/caos/zitadel/internal/test"
|
|
"github.com/caos/zitadel/internal/view/model"
|
|
admin_pb "github.com/caos/zitadel/pkg/grpc/admin"
|
|
)
|
|
|
|
func TestFailedEventsToPbFields(t *testing.T) {
|
|
type args struct {
|
|
failedEvents []*model.FailedEvent
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
}{
|
|
{
|
|
name: "all fields",
|
|
args: args{
|
|
failedEvents: []*model.FailedEvent{
|
|
{
|
|
Database: "admin",
|
|
ViewName: "users",
|
|
FailedSequence: 456,
|
|
FailureCount: 5,
|
|
ErrMsg: "some error",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got := admin_grpc.FailedEventsViewToPb(tt.args.failedEvents)
|
|
for _, g := range got {
|
|
test.AssertFieldsMapped(t, g)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestFailedEventToPbFields(t *testing.T) {
|
|
type args struct {
|
|
failedEvent *model.FailedEvent
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
}{
|
|
{
|
|
"all fields",
|
|
args{
|
|
failedEvent: &model.FailedEvent{
|
|
Database: "admin",
|
|
ViewName: "users",
|
|
FailedSequence: 456,
|
|
FailureCount: 5,
|
|
ErrMsg: "some error",
|
|
},
|
|
},
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
converted := admin_grpc.FailedEventViewToPb(tt.args.failedEvent)
|
|
test.AssertFieldsMapped(t, converted)
|
|
}
|
|
}
|
|
|
|
func TestRemoveFailedEventRequestToModelFields(t *testing.T) {
|
|
type args struct {
|
|
req *admin_pb.RemoveFailedEventRequest
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
}{
|
|
{
|
|
"all fields",
|
|
args{
|
|
req: &admin_pb.RemoveFailedEventRequest{
|
|
Database: "admin",
|
|
ViewName: "users",
|
|
FailedSequence: 456,
|
|
},
|
|
},
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
converted := admin_grpc.RemoveFailedEventRequestToModel(tt.args.req)
|
|
test.AssertFieldsMapped(t, converted, "FailureCount", "ErrMsg")
|
|
}
|
|
}
|