-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into nasdf/feat/genopenapi
- Loading branch information
Showing
34 changed files
with
3,066 additions
and
463 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
// Copyright 2024 Democratized Data Foundation | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package client | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestCollectIndexesOnField(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
desc CollectionDescription | ||
field string | ||
expected []IndexDescription | ||
}{ | ||
{ | ||
name: "no indexes", | ||
desc: CollectionDescription{ | ||
Indexes: []IndexDescription{}, | ||
}, | ||
field: "test", | ||
expected: []IndexDescription{}, | ||
}, | ||
{ | ||
name: "single index on field", | ||
desc: CollectionDescription{ | ||
Indexes: []IndexDescription{ | ||
{ | ||
Name: "index1", | ||
Fields: []IndexedFieldDescription{ | ||
{Name: "test", Direction: Ascending}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
field: "test", | ||
expected: []IndexDescription{ | ||
{ | ||
Name: "index1", | ||
Fields: []IndexedFieldDescription{ | ||
{Name: "test", Direction: Ascending}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: "multiple indexes on field", | ||
desc: CollectionDescription{ | ||
Indexes: []IndexDescription{ | ||
{ | ||
Name: "index1", | ||
Fields: []IndexedFieldDescription{ | ||
{Name: "test", Direction: Ascending}, | ||
}, | ||
}, | ||
{ | ||
Name: "index2", | ||
Fields: []IndexedFieldDescription{ | ||
{Name: "test", Direction: Descending}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
field: "test", | ||
expected: []IndexDescription{ | ||
{ | ||
Name: "index1", | ||
Fields: []IndexedFieldDescription{ | ||
{Name: "test", Direction: Ascending}, | ||
}, | ||
}, | ||
{ | ||
Name: "index2", | ||
Fields: []IndexedFieldDescription{ | ||
{Name: "test", Direction: Descending}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: "no indexes on field", | ||
desc: CollectionDescription{ | ||
Indexes: []IndexDescription{ | ||
{ | ||
Name: "index1", | ||
Fields: []IndexedFieldDescription{ | ||
{Name: "other", Direction: Ascending}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
field: "test", | ||
expected: []IndexDescription{}, | ||
}, | ||
{ | ||
name: "second field in composite index", | ||
desc: CollectionDescription{ | ||
Indexes: []IndexDescription{ | ||
{ | ||
Name: "index1", | ||
Fields: []IndexedFieldDescription{ | ||
{Name: "other", Direction: Ascending}, | ||
{Name: "test", Direction: Ascending}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
field: "test", | ||
expected: []IndexDescription{}, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
actual := tt.desc.GetIndexesOnField(tt.field) | ||
assert.Equal(t, tt.expected, actual) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.