Files
upstream-gitea/modelmigration/v28/v353_test.go
upstream-mirror 52ae0c5802
Some checks failed
cache-seeder / prune (push) Has been skipped
cache-seeder / frontend (push) Failing after 3s
cache-seeder / python (push) Failing after 3s
cache-seeder / gobuild (push) Failing after 4s
cache-seeder / lint (bindata, lint-backend) (push) Failing after 3s
giteabot backport / giteabot (push) Has been skipped
giteabot / giteabot (push) Has been skipped
cache-prune / prune (push) Has been skipped
release-nightly-snapcraft / build-and-publish (ubuntu-24.04) (push) Has been cancelled
release-nightly-snapcraft / build-and-publish (ubuntu-24.04-arm) (push) Has been cancelled
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
cron-renovate / cron-renovate (push) Has been skipped
snapshot of https://github.com/go-gitea/gitea.git (main, 2026-09-15; blobs > 131072B omitted)
2026-09-15 21:41:59 +05:00

49 lines
1.0 KiB
Go

// Copyright 2026 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package v28
import (
"context"
"slices"
"testing"
"gitea.dev/modelmigration/migrationtest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"xorm.io/xorm/schemas"
)
func TestAddAuditEventTable(t *testing.T) {
x, deferable := migrationtest.PrepareTestEnv(t, 0)
defer deferable()
if x == nil || t.Failed() {
return
}
require.NoError(t, AddAuditEventTable(t.Context(), x))
indexes, err := x.Dialect().GetIndexes(x.DB(), context.Background(), "audit_event")
require.NoError(t, err)
for _, columns := range [][]string{
{"action"},
{"actor_id"},
{"scope_id", "scope_type"},
{"scope_type"},
{"origin"},
{"timestamp_unix"},
} {
assert.True(t, hasAuditIndexWithColumns(indexes, columns), "missing index on %v", columns)
}
}
func hasAuditIndexWithColumns(indexes map[string]*schemas.Index, columns []string) bool {
for _, index := range indexes {
if slices.Equal(index.Cols, columns) {
return true
}
}
return false
}