Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make listIndexes return a sorted list #3602

Merged
merged 10 commits into from
Oct 20, 2023
Prev Previous commit
Next Next commit
update index sorting tests
  • Loading branch information
codenoid committed Oct 17, 2023
commit 0ea2369507ff4c2c5f3779d5033fb377af848894
11 changes: 4 additions & 7 deletions internal/backends/postgresql/metadata/registry_test.go
codenoid marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package metadata

import (
"cmp"
"context"
"fmt"
"slices"
Expand Down Expand Up @@ -495,13 +496,9 @@
require.NoError(t, err)

t.Run("IndexOrder", func(t *testing.T) {
t.Parallel()

require.Equal(t, 4, len(collection.Indexes))
require.Equal(t, "_id_", collection.Indexes[0].Name)
require.Equal(t, "index_non_unique", collection.Indexes[1].Name)
require.Equal(t, "index_unique", collection.Indexes[2].Name)
require.Equal(t, "nested_fields", collection.Indexes[3].Name)
require.Equal(t, slices.IsSortedFunc(collection.Indexes, func(a, b IndexInfo) int {

Check failure on line 499 in internal/backends/postgresql/metadata/registry_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

arg list parens: move `)` to the next line and put `,` after the last argument
return cmp.Compare(a.Name, b.Name)
}), true)
})

t.Run("CreateIndexes", func(t *testing.T) {
Expand Down
9 changes: 5 additions & 4 deletions internal/backends/sqlite/metadata/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
package metadata

import (
"cmp"
"context"
"fmt"
"slices"
"sync/atomic"
"testing"

Expand Down Expand Up @@ -389,10 +391,9 @@
collection := r.CollectionGet(ctx, dbName, collectionName)

t.Run("IndexOrder", func(t *testing.T) {
require.Equal(t, 3, len(collection.Settings.Indexes))
require.Equal(t, "_id_", collection.Settings.Indexes[0].Name)
require.Equal(t, "index_non_unique", collection.Settings.Indexes[1].Name)
require.Equal(t, "index_unique", collection.Settings.Indexes[2].Name)
require.Equal(t, slices.IsSortedFunc(collection.Settings.Indexes, func(a, b IndexInfo) int {

Check failure on line 394 in internal/backends/sqlite/metadata/registry_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

arg list parens: move `)` to the next line and put `,` after the last argument
return cmp.Compare(a.Name, b.Name)
}), true)
})

t.Run("NonUniqueIndex", func(t *testing.T) {
Expand Down
Loading