mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-14 20:08:02 +00:00
29441ce4b6
* fix: filter failed events and current sequence correctly * fix failed events sorting column * feat: save last occurrence of failed event * fix failedEvents query and update sql statements * change sql statement to only create index * fix linting * fix linting * Update internal/query/failed_events.go Co-authored-by: Silvan <silvan.reusser@gmail.com> * update job name on test-docs to match the one from test-code Co-authored-by: Silvan <silvan.reusser@gmail.com>
102 lines
2.0 KiB
Go
102 lines
2.0 KiB
Go
package admin
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/zitadel/zitadel/internal/api/authz"
|
|
"github.com/zitadel/zitadel/internal/test"
|
|
"github.com/zitadel/zitadel/internal/view/model"
|
|
admin_pb "github.com/zitadel/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,
|
|
LastFailed: time.Now(),
|
|
ErrMsg: "some error",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got := 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,
|
|
LastFailed: time.Now(),
|
|
ErrMsg: "some error",
|
|
},
|
|
},
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
converted := FailedEventViewToPb(tt.args.failedEvent)
|
|
test.AssertFieldsMapped(t, converted)
|
|
}
|
|
}
|
|
|
|
func TestRemoveFailedEventRequestToModelFields(t *testing.T) {
|
|
type args struct {
|
|
ctx context.Context
|
|
req *admin_pb.RemoveFailedEventRequest
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
}{
|
|
{
|
|
"all fields",
|
|
args{
|
|
ctx: authz.WithInstanceID(context.Background(), "instanceID"),
|
|
req: &admin_pb.RemoveFailedEventRequest{
|
|
Database: "admin",
|
|
ViewName: "users",
|
|
FailedSequence: 456,
|
|
},
|
|
},
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
converted := RemoveFailedEventRequestToModel(tt.args.ctx, tt.args.req)
|
|
test.AssertFieldsMapped(t, converted, "FailureCount", "LastFailed", "ErrMsg")
|
|
}
|
|
}
|