Skip to content
Snippets Groups Projects
Unverified Commit 96675fe9 authored by john-metabase's avatar john-metabase Committed by GitHub
Browse files

Adds list of exported settings, basic test (#29927)

Many settings are inappropriate for transfer between instances, so exported settings are limited to a subset of settings
related to appearance and UI behavior of the instance.
parent 2fcc70f8
No related branches found
No related tags found
No related merge requests found
......@@ -18,6 +18,7 @@
Table]]
[metabase.models.action :as action]
[metabase.models.serialization :as serdes]
[metabase.models.setting :as setting]
[metabase.test :as mt]
[metabase.test.generate :as test-gen]
[metabase.util.yaml :as yaml]
......@@ -416,9 +417,12 @@
clean-entity)))))
(testing "for settings"
(is (= (into {} (for [{:keys [key value]} (get @entities "Setting")]
[key value]))
(yaml/from-file (io/file dump-dir "settings.yaml"))))))))))))
(let [settings (get @entities "Setting")]
(is (every? @#'setting/exported-settings
(set (map (comp symbol :key) settings))))
(is (= (into {} (for [{:keys [key value]} settings]
[key value]))
(yaml/from-file (io/file dump-dir "settings.yaml")))))))))))))
;; This is a seperate test instead of a `testing` block inside `e2e-storage-ingestion-test`
;; because it's quite tricky to set up the generative test to generate parameters with source is card
......
......@@ -148,9 +148,52 @@
[_setting]
[:key])
(def ^:private exported-settings
'#{application-colors
application-favicon-url
application-font
application-font-files
application-logo-url
application-name
available-fonts
available-locales
available-timezones
breakout-bins-num
custom-formatting
custom-geojson
custom-geojson-enabled
enable-content-management?
enable-embedding
enable-nested-queries
enable-sandboxes?
enable-whitelabeling?
enable-xrays
hide-embed-branding?
humanization-strategy
landing-page
loading-message
max-results-bare-rows
native-query-autocomplete-match-style
persisted-models-enabled
report-timezone
report-timezone-long
report-timezone-short
search-typeahead-enabled
show-homepage-data
show-homepage-pin-message
show-homepage-xrays
show-lighthouse-illustration
show-metabot
site-locale
site-name
source-address-header
start-of-week
subscription-allowed-domains})
(defmethod serdes/extract-all "Setting" [_model _opts]
(for [{:keys [key value]} (admin-writable-site-wide-settings
:getter (partial get-value-of-type :string))]
:getter (partial get-value-of-type :string))
:when (contains? exported-settings (symbol key))]
{:serdes/meta [{:model "Setting" :id (name key)}]
:key key
:value value}))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment