This repository has been archived by the owner on Oct 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
provisions to identify fields with multiple value #5109
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6faf18c
provisions to identify fields with multiple value
HiteshRepo b770d02
fix test TestColumnDefinitionable_LegacyColumns
HiteshRepo 162d32e
updates function name that sets multiple enabled by data type
HiteshRepo e2f2732
skips setting odatatype for text columns
HiteshRepo 98b7e5e
fix lint
HiteshRepo abdf620
Merge remote-tracking branch 'origin/main' into lists-multiple
HiteshRepo 55aed0d
address review comment
HiteshRepo 3b2bdc5
Merge branch 'main' into lists-multiple
aviator-app[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -162,12 +162,12 @@ func (suite *ListsUnitSuite) TestColumnDefinitionable_GetValidation() { | |
for _, test := range tests { | ||
suite.Run(test.name, func() { | ||
t := suite.T() | ||
colNames := map[string]*columnDetails{} | ||
|
||
orig := test.getOrig() | ||
newCd := cloneColumnDefinitionable(orig) | ||
newCd := cloneColumnDefinitionable(orig, colNames) | ||
|
||
require.NotEmpty(t, newCd) | ||
|
||
test.expect(t, newCd.GetValidation()) | ||
}) | ||
} | ||
|
@@ -219,9 +219,10 @@ func (suite *ListsUnitSuite) TestColumnDefinitionable_GetDefaultValue() { | |
for _, test := range tests { | ||
suite.Run(test.name, func() { | ||
t := suite.T() | ||
colNames := map[string]*columnDetails{} | ||
|
||
orig := test.getOrig() | ||
newCd := cloneColumnDefinitionable(orig) | ||
newCd := cloneColumnDefinitionable(orig, colNames) | ||
|
||
require.NotEmpty(t, newCd) | ||
test.expect(t, newCd) | ||
|
@@ -277,9 +278,8 @@ func (suite *ListsUnitSuite) TestColumnDefinitionable_ColumnType() { | |
for _, test := range tests { | ||
suite.Run(test.name, func() { | ||
t := suite.T() | ||
|
||
orig := test.getOrig() | ||
newCd := cloneColumnDefinitionable(orig) | ||
colNames := map[string]*columnDetails{} | ||
newCd := cloneColumnDefinitionable(test.getOrig(), colNames) | ||
|
||
require.NotEmpty(t, newCd) | ||
assert.True(t, test.checkFn(newCd)) | ||
|
@@ -332,7 +332,7 @@ func (suite *ListsUnitSuite) TestColumnDefinitionable_LegacyColumns() { | |
name string | ||
getList func() *models.List | ||
length int | ||
expectedColNames map[string]any | ||
expectedColNames map[string]*columnDetails | ||
}{ | ||
{ | ||
name: "all legacy columns", | ||
|
@@ -346,7 +346,7 @@ func (suite *ListsUnitSuite) TestColumnDefinitionable_LegacyColumns() { | |
return lst | ||
}, | ||
length: 0, | ||
expectedColNames: map[string]any{TitleColumnName: nil}, | ||
expectedColNames: map[string]*columnDetails{TitleColumnName: {}}, | ||
}, | ||
{ | ||
name: "title and legacy columns", | ||
|
@@ -361,7 +361,7 @@ func (suite *ListsUnitSuite) TestColumnDefinitionable_LegacyColumns() { | |
return lst | ||
}, | ||
length: 0, | ||
expectedColNames: map[string]any{TitleColumnName: nil}, | ||
expectedColNames: map[string]*columnDetails{TitleColumnName: {}}, | ||
}, | ||
{ | ||
name: "readonly and legacy columns", | ||
|
@@ -376,7 +376,7 @@ func (suite *ListsUnitSuite) TestColumnDefinitionable_LegacyColumns() { | |
return lst | ||
}, | ||
length: 0, | ||
expectedColNames: map[string]any{TitleColumnName: nil}, | ||
expectedColNames: map[string]*columnDetails{TitleColumnName: {}}, | ||
}, | ||
{ | ||
name: "legacy and a text column", | ||
|
@@ -391,9 +391,9 @@ func (suite *ListsUnitSuite) TestColumnDefinitionable_LegacyColumns() { | |
return lst | ||
}, | ||
length: 1, | ||
expectedColNames: map[string]any{ | ||
TitleColumnName: nil, | ||
textColumnName: nil, | ||
expectedColNames: map[string]*columnDetails{ | ||
TitleColumnName: {}, | ||
textColumnName: {}, | ||
}, | ||
}, | ||
} | ||
|
@@ -432,7 +432,7 @@ func (suite *ListsUnitSuite) TestFieldValueSetable() { | |
origFs := models.NewFieldValueSet() | ||
origFs.SetAdditionalData(additionalData) | ||
|
||
colNames := map[string]any{} | ||
colNames := map[string]*columnDetails{} | ||
|
||
fs := retrieveFieldData(origFs, colNames) | ||
fsAdditionalData := fs.GetAdditionalData() | ||
|
@@ -442,7 +442,7 @@ func (suite *ListsUnitSuite) TestFieldValueSetable() { | |
origFs = models.NewFieldValueSet() | ||
origFs.SetAdditionalData(additionalData) | ||
|
||
colNames["itemName"] = struct{}{} | ||
colNames["itemName"] = &columnDetails{} | ||
|
||
fs = retrieveFieldData(origFs, colNames) | ||
fsAdditionalData = fs.GetAdditionalData() | ||
|
@@ -509,8 +509,8 @@ func (suite *ListsUnitSuite) TestFieldValueSetable_Location() { | |
origFs := models.NewFieldValueSet() | ||
origFs.SetAdditionalData(additionalData) | ||
|
||
colNames := map[string]any{ | ||
"MyAddress": nil, | ||
colNames := map[string]*columnDetails{ | ||
"MyAddress": {}, | ||
} | ||
|
||
fs := retrieveFieldData(origFs, colNames) | ||
|
@@ -703,6 +703,75 @@ func (suite *ListsUnitSuite) TestConcatenateHyperlinkFields() { | |
} | ||
} | ||
|
||
func (suite *ListsUnitSuite) TestSetAdditionalDataByColumnNames() { | ||
t := suite.T() | ||
|
||
tests := []struct { | ||
name string | ||
additionalData map[string]any | ||
colName string | ||
assertFn assert.BoolAssertionFunc | ||
}{ | ||
{ | ||
name: "choice column, single value", | ||
additionalData: map[string]any{ | ||
"choice": "good", | ||
}, | ||
colName: "choice", | ||
assertFn: assert.False, | ||
}, | ||
{ | ||
name: "choice column, multiple values", | ||
additionalData: map[string]any{ | ||
"choice": []string{"good", "ok"}, | ||
}, | ||
colName: "choice", | ||
assertFn: assert.True, | ||
}, | ||
{ | ||
name: "person column, single value", | ||
additionalData: map[string]any{ | ||
"PersonsLookupId": 10, | ||
}, | ||
colName: "PersonsLookupId", | ||
assertFn: assert.False, | ||
}, | ||
{ | ||
name: "person column, multiple values", | ||
additionalData: map[string]any{ | ||
"Persons": []map[string]any{ | ||
{ | ||
"LookupId": 10, | ||
"LookupValue": "Who1", | ||
"Email": "[email protected]", | ||
}, | ||
{ | ||
"LookupId": 11, | ||
"LookupValue": "Who2", | ||
"Email": "[email protected]", | ||
}, | ||
}, | ||
}, | ||
colName: "Persons", | ||
assertFn: assert.True, | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
origFs := models.NewFieldValueSet() | ||
origFs.SetAdditionalData(test.additionalData) | ||
|
||
colNames := map[string]*columnDetails{ | ||
test.colName: {}, | ||
} | ||
|
||
suite.Run(test.name, func() { | ||
setAdditionalDataByColumnNames(origFs, colNames) | ||
test.assertFn(t, colNames[test.colName].isMultipleEnabled) | ||
}) | ||
} | ||
} | ||
|
||
type ListsAPIIntgSuite struct { | ||
tester.Suite | ||
its intgTesterSetup | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preference on general func behavior: rather than setting values a provided object (which causes coupling between the caller and the func), funcs that provide return values and let callers act on them (which provides cohesion without coupling), are easier to maintain in the long term. In this case, it's a better pattern to have a func whose only job is to check whether the value is a slice. Ex: