1
0
mirror of https://github.com/mattermost/focalboard.git synced 2025-01-23 18:34:02 +02:00

Added duplicate data test for user preference (#3968)

* Added handling of duplicate key conflicts

* Added a test

* Add value checks and fix username for the test

Co-authored-by: Miguel de la Cruz <miguel@mcrx.me>
This commit is contained in:
Harshil Sharma 2022-10-07 19:58:47 +05:30 committed by GitHub
parent a40f978bc2
commit f5a068e382
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -1,4 +1,9 @@
INSERT INTO focalboard_users
(id, username, props)
VALUES
('user-id', 'johndoe', '{"focalboard_welcomePageViewed": true, "hiddenBoardIDs": ["board1", "board2"], "focalboard_tourCategory": "onboarding", "focalboard_onboardingTourStep": 1, "focalboard_onboardingTourStarted": true, "focalboard_version72MessageCanceled": true, "focalboard_lastWelcomeVersion": 7}');
('user-id', 'johndoe', '{"focalboard_welcomePageViewed": true, "hiddenBoardIDs": ["board1", "board2"], "focalboard_tourCategory": "onboarding", "focalboard_onboardingTourStep": 1, "focalboard_onboardingTourStarted": false, "focalboard_version72MessageCanceled": true, "focalboard_lastWelcomeVersion": 7}');
INSERT INTO focalboard_preferences
(UserId, Category, Name, Value)
VALUES
('user-id', 'focalboard', 'onboardingTourStarted', true);

View File

@ -40,7 +40,11 @@ func Test27MigrateUserPropsToPreferences(t *testing.T) {
require.Contains(t, userProps, "focalboard_onboardingTourStep")
require.Equal(t, float64(1), userProps["focalboard_onboardingTourStep"])
require.Contains(t, userProps, "focalboard_onboardingTourStarted")
require.True(t, userProps["focalboard_onboardingTourStarted"].(bool))
// initially, onboardingTourStarted will be false on the user,
// but already inserted in the preferences table as true. The
// migration should not overwrite the already existing value,
// so after migration #27, this value should be true
require.False(t, userProps["focalboard_onboardingTourStarted"].(bool))
require.Contains(t, userProps, "focalboard_version72MessageCanceled")
require.True(t, userProps["focalboard_version72MessageCanceled"].(bool))
require.Contains(t, userProps, "focalboard_lastWelcomeVersion")