From 787b5d40394889510c24f4abc3a08410ecc96e5e Mon Sep 17 00:00:00 2001 From: Dimitry Kolyshev Date: Wed, 31 Jul 2024 15:09:18 +0300 Subject: [PATCH] configmigrate: revert --- internal/configmigrate/configmigrate.go | 2 +- .../configmigrate/migrations_internal_test.go | 60 ------------------- internal/configmigrate/migrator.go | 1 - internal/configmigrate/v29.go | 47 --------------- 4 files changed, 1 insertion(+), 109 deletions(-) delete mode 100644 internal/configmigrate/v29.go diff --git a/internal/configmigrate/configmigrate.go b/internal/configmigrate/configmigrate.go index cba61247..6e8845e0 100644 --- a/internal/configmigrate/configmigrate.go +++ b/internal/configmigrate/configmigrate.go @@ -2,4 +2,4 @@ package configmigrate // LastSchemaVersion is the most recent schema version. -const LastSchemaVersion uint = 29 +const LastSchemaVersion uint = 28 diff --git a/internal/configmigrate/migrations_internal_test.go b/internal/configmigrate/migrations_internal_test.go index 2a3b7596..5349102f 100644 --- a/internal/configmigrate/migrations_internal_test.go +++ b/internal/configmigrate/migrations_internal_test.go @@ -1728,63 +1728,3 @@ func TestUpgradeSchema27to28(t *testing.T) { }) } } - -func TestUpgradeSchema28to29(t *testing.T) { - const newSchemaVer = 29 - - testCases := []struct { - in yobj - want yobj - name string - }{{ - name: "empty", - in: yobj{}, - want: yobj{ - "schema_version": newSchemaVer, - }, - }, { - name: "disabled", - in: yobj{ - "dns": yobj{ - "safe_search": yobj{ - "enabled": false, - }, - }, - }, - want: yobj{ - "schema_version": newSchemaVer, - "dns": yobj{ - "safe_search": yobj{ - "enabled": false, - }, - }, - }, - }, { - name: "enabled", - in: yobj{ - "dns": yobj{ - "safe_search": yobj{ - "enabled": true, - }, - }, - }, - want: yobj{ - "schema_version": newSchemaVer, - "dns": yobj{ - "safe_search": yobj{ - "ecosia": true, - "enabled": true, - }, - }, - }, - }} - - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - err := migrateTo29(tc.in) - require.NoError(t, err) - - assert.Equal(t, tc.want, tc.in) - }) - } -} diff --git a/internal/configmigrate/migrator.go b/internal/configmigrate/migrator.go index 06dbdb90..ebdf6ba7 100644 --- a/internal/configmigrate/migrator.go +++ b/internal/configmigrate/migrator.go @@ -120,7 +120,6 @@ func (m *Migrator) upgradeConfigSchema(current, target uint, diskConf yobj) (err 25: migrateTo26, 26: migrateTo27, 27: migrateTo28, - 28: migrateTo29, } for i, migrate := range upgrades[current:target] { diff --git a/internal/configmigrate/v29.go b/internal/configmigrate/v29.go deleted file mode 100644 index ec174131..00000000 --- a/internal/configmigrate/v29.go +++ /dev/null @@ -1,47 +0,0 @@ -package configmigrate - -// migrateTo29 performs the following changes: -// -// # BEFORE: -// 'dns': -// 'safe_search': -// 'enabled': true -// 'bing': true -// 'duckduckgo': true -// 'google': true -// 'pixabay': true -// 'yandex': true -// 'youtube': true -// # … -// # … -// -// # AFTER: -// 'dns': -// 'safe_search': -// 'enabled': true -// 'bing': true -// 'duckduckgo': true -// 'ecosia': true -// 'google': true -// 'pixabay': true -// 'yandex': true -// 'youtube': true -// # … -// # … -func migrateTo29(diskConf yobj) (err error) { - diskConf["schema_version"] = 29 - - dns, ok, err := fieldVal[yobj](diskConf, "dns") - if !ok { - return err - } - - safeSearch, _, _ := fieldVal[yobj](dns, "safe_search") - if safeSearch["enabled"] == true { - safeSearch["ecosia"] = true - } - - dns["safe_search"] = safeSearch - - return nil -}