[#2817] allowed 0 as RelationOptions.MinSelect value
This commit is contained in:
@@ -2112,6 +2112,22 @@ func TestRelationOptionsValidate(t *testing.T) {
|
||||
},
|
||||
[]string{"collectionId"},
|
||||
},
|
||||
{
|
||||
"MinSelect < 0",
|
||||
schema.RelationOptions{
|
||||
CollectionId: "abc",
|
||||
MinSelect: types.Pointer(-1),
|
||||
},
|
||||
[]string{"minSelect"},
|
||||
},
|
||||
{
|
||||
"MinSelect >= 0",
|
||||
schema.RelationOptions{
|
||||
CollectionId: "abc",
|
||||
MinSelect: types.Pointer(0),
|
||||
},
|
||||
[]string{},
|
||||
},
|
||||
{
|
||||
"MaxSelect <= 0",
|
||||
schema.RelationOptions{
|
||||
@@ -2128,6 +2144,42 @@ func TestRelationOptionsValidate(t *testing.T) {
|
||||
},
|
||||
[]string{},
|
||||
},
|
||||
{
|
||||
"MinSelect < MaxSelect",
|
||||
schema.RelationOptions{
|
||||
CollectionId: "abc",
|
||||
MinSelect: nil,
|
||||
MaxSelect: types.Pointer(1),
|
||||
},
|
||||
[]string{},
|
||||
},
|
||||
{
|
||||
"MinSelect = MaxSelect (non-zero)",
|
||||
schema.RelationOptions{
|
||||
CollectionId: "abc",
|
||||
MinSelect: types.Pointer(1),
|
||||
MaxSelect: types.Pointer(1),
|
||||
},
|
||||
[]string{},
|
||||
},
|
||||
{
|
||||
"MinSelect = MaxSelect (both zero)",
|
||||
schema.RelationOptions{
|
||||
CollectionId: "abc",
|
||||
MinSelect: types.Pointer(0),
|
||||
MaxSelect: types.Pointer(0),
|
||||
},
|
||||
[]string{"maxSelect"},
|
||||
},
|
||||
{
|
||||
"MinSelect > MaxSelect",
|
||||
schema.RelationOptions{
|
||||
CollectionId: "abc",
|
||||
MinSelect: types.Pointer(2),
|
||||
MaxSelect: types.Pointer(1),
|
||||
},
|
||||
[]string{"maxSelect"},
|
||||
},
|
||||
}
|
||||
|
||||
checkFieldOptionsScenarios(t, scenarios)
|
||||
|
||||
Reference in New Issue
Block a user