Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
7295a3b9
Commit
7295a3b9
authored
10 years ago
by
Cam Saul
Browse files
Options
Downloads
Patches
Plain Diff
Add unit tests. Update dox
parent
39adedf5
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/metabase/models/setting.clj
+1
-1
1 addition, 1 deletion
src/metabase/models/setting.clj
test/metabase/api/setting_test.clj
+2
-2
2 additions, 2 deletions
test/metabase/api/setting_test.clj
test/metabase/models/setting_test.clj
+30
-11
30 additions, 11 deletions
test/metabase/models/setting_test.clj
with
33 additions
and
14 deletions
src/metabase/models/setting.clj
+
1
−
1
View file @
7295a3b9
...
...
@@ -42,7 +42,7 @@
;; ## ACCESSORS
(
defn
get
"Fetch value of `Setting`.
"Fetch value of `Setting`
, or return default value if none is set
.
Cached lookup time is ~60µs, compared to ~1800µs for DB lookup."
[
k
]
{
:pre
[(
keyword?
k
)]}
...
...
This diff is collapsed.
Click to expand it.
test/metabase/api/setting_test.clj
+
2
−
2
View file @
7295a3b9
...
...
@@ -20,8 +20,8 @@
;; ## GET /api/setting
;; Check that we can fetch all Settings for Org
(
expect-eval-actual-first
[{
:key
"test-setting-1"
,
:value
nil,
:description
"Test setting - this only shows up in dev (1)"
}
{
:key
"test-setting-2"
,
:value
"FANCY"
,
:description
"Test setting - this only shows up in dev (2)"
}]
[{
:key
"test-setting-1"
,
:value
nil,
:description
"Test setting - this only shows up in dev (1)"
,
:default
nil
}
{
:key
"test-setting-2"
,
:value
"FANCY"
,
:description
"Test setting - this only shows up in dev (2)"
,
:default
"[Default Value]"
}]
(
do
(
set-settings
nil
"FANCY"
)
(
fetch-all-settings
)))
...
...
This diff is collapsed.
Click to expand it.
test/metabase/models/setting_test.clj
+
30
−
11
View file @
7295a3b9
...
...
@@ -12,7 +12,8 @@
;; these tests will fail. FIXME
(
defsetting
test-setting-1
"Test setting - this only shows up in dev (1)"
)
(
defsetting
test-setting-2
"Test setting - this only shows up in dev (2)"
)
(
defsetting
test-setting-2
"Test setting - this only shows up in dev (2)"
"[Default Value]"
)
;; ## HELPER FUNCTIONS
...
...
@@ -39,7 +40,12 @@
;; Test `get` function
(
expect
nil
(
do
(
set-settings
nil
nil
)
(
setting/get
:test-setting-1
)))
(
setting/get
:test-setting-1
)))
;; Test getting a default value
(
expect
"[Default Value]"
(
do
(
set-settings
nil
nil
)
(
test-setting-2
)))
;; ## SETTERS
...
...
@@ -61,12 +67,25 @@
;; ## DELETE
;; Test defsetting delete
;; Test defsetting delete
w/o default value
(
expect-eval-actual-first
[
"COOL"
true
nil
false
]
[(
do
(
test-setting-1
"COOL"
)
(
test-setting-1
))
(
setting-exists?
:test-setting-1
)
(
do
(
test-setting-1
nil
)
(
test-setting-1
))
(
setting-exists?
:test-setting-1
)])
;; Test defsetting delete w/ default value
(
expect-eval-actual-first
[
"COOL"
true
"[Default Value]"
; default value should get returned if none is set
false
]
; setting still shouldn't exist in the DB
[(
do
(
test-setting-2
"COOL"
)
(
test-setting-2
))
(
setting-exists?
:test-setting-2
)
...
...
@@ -80,12 +99,12 @@
true
nil
false
]
[(
do
(
test-setting-
2
"VERY NICE!"
)
(
test-setting-
2
))
(
setting-exists?
:test-setting-
2
)
(
do
(
test-setting-
2
nil
)
(
test-setting-
2
))
(
setting-exists?
:test-setting-
2
)])
[(
do
(
test-setting-
1
"VERY NICE!"
)
(
test-setting-
1
))
(
setting-exists?
:test-setting-
1
)
(
do
(
test-setting-
1
nil
)
(
test-setting-
1
))
(
setting-exists?
:test-setting-
1
)])
;; ## ALL SETTINGS FUNCTIONS
...
...
@@ -98,8 +117,8 @@
;; all-with-descriptions
(
expect-eval-actual-first
[{
:key
:test-setting-1,
:value
nil,
:description
"Test setting - this only shows up in dev (1)"
}
{
:key
:test-setting-2,
:value
"S2"
,
:description
"Test setting - this only shows up in dev (2)"
}]
[{
:key
:test-setting-1,
:value
nil,
:description
"Test setting - this only shows up in dev (1)"
,
:default
nil
}
{
:key
:test-setting-2,
:value
"S2"
,
:description
"Test setting - this only shows up in dev (2)"
,
:default
"[Default Value]"
}]
(
do
(
set-settings
nil
"S2"
)
(
filter
(
fn
[{
k
:key
}]
(
re-find
#
"^test-setting-\d$"
(
name
k
)))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment