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
0b58a477
Commit
0b58a477
authored
10 years ago
by
Cam Saul
Browse files
Options
Downloads
Patches
Plain Diff
tests for /api/result
parent
8aa73351
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
project.clj
+43
-43
43 additions, 43 deletions
project.clj
test/metabase/api/result_test.clj
+54
-0
54 additions, 0 deletions
test/metabase/api/result_test.clj
with
97 additions
and
43 deletions
project.clj
+
43
−
43
View file @
0b58a477
;; -*- comment-column: 6
0
; -*-
;; -*- comment-column: 6
5
; -*-
;; full set of options are here .. https://github.com/technomancy/leiningen/blob/master/sample.project.clj
(
defproject
metabase
"metabase-0.1.0-SNAPSHOT"
...
...
@@ -6,46 +6,46 @@
:url
"http://metabase.com/"
:min-lein-version
"2.3.0"
:dependencies
[[
org.clojure/clojure
"1.6.0"
]
[
org.clojure/core.async
"LATEST"
]
; facilities for async programming + communication (using 'LATEST' because this is an alpha library)
[
org.clojure/core.match
"0.3.0-alpha4"
]
; optimized pattern matching library for Clojure
[
org.clojure/math.numeric-tower
"0.0.4"
]
; math functions like `ceil`
[
org.clojure/core.memoize
"0.5.7"
]
; needed by core.match; has useful FIFO, LRU, etc. caching mechanisms
[
org.clojure/data.csv
"0.1.2"
]
; CSV parsing / generation
[
org.clojure/data.json
"0.2.6"
]
; JSON parsing / generation
[
org.clojure/java.jdbc
"0.3.6"
]
; basic jdbc access from clojure
[
org.clojure/tools.logging
"0.3.1"
]
; logging framework
[
org.clojure/tools.macro
"0.1.5"
]
; tools for writing macros
[
org.clojure/tools.trace
"0.7.8"
]
; "tracing macros/fns to help you see what your code is doing"
[
cheshire
"5.4.0"
]
; fast JSON encoding (used by Ring JSON middleware)
[
clj-time
"0.9.0"
]
; library for dealing with date/time
[
com.cemerick/friend
"0.2.1"
]
; auth library
[
com.h2database/h2
"1.4.186"
]
; embedded SQL database
[
org.clojure/core.async
"LATEST"
]
; facilities for async programming + communication (using 'LATEST' because this is an alpha library)
[
org.clojure/core.match
"0.3.0-alpha4"
]
; optimized pattern matching library for Clojure
[
org.clojure/math.numeric-tower
"0.0.4"
]
; math functions like `ceil`
[
org.clojure/core.memoize
"0.5.7"
]
; needed by core.match; has useful FIFO, LRU, etc. caching mechanisms
[
org.clojure/data.csv
"0.1.2"
]
; CSV parsing / generation
[
org.clojure/data.json
"0.2.6"
]
; JSON parsing / generation
[
org.clojure/java.jdbc
"0.3.6"
]
; basic jdbc access from clojure
[
org.clojure/tools.logging
"0.3.1"
]
; logging framework
[
org.clojure/tools.macro
"0.1.5"
]
; tools for writing macros
[
org.clojure/tools.trace
"0.7.8"
]
; "tracing macros/fns to help you see what your code is doing"
[
cheshire
"5.4.0"
]
; fast JSON encoding (used by Ring JSON middleware)
[
clj-time
"0.9.0"
]
; library for dealing with date/time
[
com.cemerick/friend
"0.2.1"
]
; auth library
[
com.h2database/h2
"1.4.186"
]
; embedded SQL database
[
com.mattbertolini/liquibase-slf4j
"1.2.1"
]
[
compojure
"1.3.2"
]
; HTTP Routing library built on Ring
[
environ
"1.0.0"
]
; easy environment management
[
korma
"0.4.0"
]
; SQL lib
[
compojure
"1.3.2"
]
; HTTP Routing library built on Ring
[
environ
"1.0.0"
]
; easy environment management
[
korma
"0.4.0"
]
; SQL lib
[
log4j/log4j
"1.2.17"
:exclusions
[
javax.mail/mail
javax.jms/jms
com.sun.jdmk/jmxtools
com.sun.jmx/jmxri
]]
[
marginalia
"0.8.0"
]
; for documentation
[
medley
"0.5.5"
]
; lightweight lib of useful functions
[
org.apache.httpcomponents/httpclient
"4.
3.5
"
]
[
org.liquibase/liquibase-core
"3.3.2"
]
; migration management (Java lib)
[
marginalia
"0.8.0"
]
; for documentation
[
medley
"0.5.5"
]
; lightweight lib of useful functions
[
org.apache.httpcomponents/httpclient
"4.
4
"
]
[
org.liquibase/liquibase-core
"3.3.2"
]
; migration management (Java lib)
[
org.slf4j/slf4j-log4j12
"1.7.10"
]
[
org.yaml/snakeyaml
"1.15"
]
; YAML parser (required by liquibase)
[
postgresql
"9.3-1102.jdbc41"
]
; Postgres driver
[
ring/ring-jetty-adapter
"1.3.2"
]
; Ring adapter using Jetty webserver (used to run a Ring server for unit tests)
[
ring/ring-json
"0.3.1"
]
; Ring middleware for reading/writing JSON automatically
[
swiss-arrows
"1.0.0"
]]
; 'Magic wand' macro -<>, etc.
:plugins
[[
cider/cider-nrepl
"0.9.0-SNAPSHOT"
]
; Interactive development w/ cider NREPL in Emacs
[
jonase/eastwood
"0.2.1"
]
; Linting
[
lein-ancient
"0.6.4"
]
; Check project for outdated dependencies + plugins w/ 'lein ancient'
[
lein-environ
"0.5.0"
]
; easy access to environment variables
[
lein-expectations
"0.0.7"
]
; run unit tests with 'lein expectations'
[
lein-marginalia
"LATEST"
]
; generate documentation with 'lein marg'
[
lein-ring
"0.8.10"
]]
; start the HTTP server with 'lein ring server'
[
org.yaml/snakeyaml
"1.15"
]
; YAML parser (required by liquibase)
[
postgresql
"9.3-1102.jdbc41"
]
; Postgres driver
[
ring/ring-jetty-adapter
"1.3.2"
]
; Ring adapter using Jetty webserver (used to run a Ring server for unit tests)
[
ring/ring-json
"0.3.1"
]
; Ring middleware for reading/writing JSON automatically
[
swiss-arrows
"1.0.0"
]]
; 'Magic wand' macro -<>, etc.
:plugins
[[
cider/cider-nrepl
"0.9.0-SNAPSHOT"
]
; Interactive development w/ cider NREPL in Emacs
[
jonase/eastwood
"0.2.1"
]
; Linting
[
lein-ancient
"0.6.4"
]
; Check project for outdated dependencies + plugins w/ 'lein ancient'
[
lein-environ
"0.5.0"
]
; easy access to environment variables
[
lein-expectations
"0.0.7"
]
; run unit tests with 'lein expectations'
[
lein-marginalia
"LATEST"
]
; generate documentation with 'lein marg'
[
lein-ring
"0.8.10"
]]
; start the HTTP server with 'lein ring server'
:java-source-paths
[
"src/java"
]
:main
^
:skip-aot
metabase.core
:manifest
{
"Liquibase-Package"
"liquibase.change,liquibase.changelog,liquibase.database,liquibase.parser,liquibase.precondition,liquibase.datatype,liquibase.serializer,liquibase.sqlgenerator,liquibase.executor,liquibase.snapshot,liquibase.logging,liquibase.diff,liquibase.structure,liquibase.structurecompare,liquibase.lockservice,liquibase.sdk,liquibase.ext"
}
...
...
@@ -55,16 +55,16 @@
:init
metabase.core/init
}
:eastwood
{
:exclude-namespaces
[
:test-paths
]
:add-linters
[
:unused-private-vars
]
:exclude-linters
[
:constant-test
]}
; korma macros generate some formats with if statements that are always logically true or false
:profiles
{
:dev
{
:dependencies
[[
clj-http
"1.0.1"
]
; HTTP Client
[
expectations
"2.0.16"
]
; unit tests
:exclude-linters
[
:constant-test
]}
; korma macros generate some formats with if statements that are always logically true or false
:profiles
{
:dev
{
:dependencies
[[
clj-http
"1.0.1"
]
; HTTP Client
[
expectations
"2.0.16"
]
; unit tests
[
ring/ring-mock
"0.2.0"
]]
:jvm-opts
[
"-Dlogfile.path=target/log"
"-Xms1024m"
; give JVM a decent heap size to start with
"-Xmx2048m"
; hard limit of 2GB so we stop hitting the 4GB container limit on CircleCI
"-XX:PermSize=64m"
; start with a little more PermGen space
"-XX:MaxPermSize=128m"
; a little more headroom for PermGen
"-XX:+CMSClassUnloadingEnabled"
; let Clojure's dynamically generated temporary classes be GC'ed from PermGen
"-XX:+UseConcMarkSweepGC"
]}
; Concurrent Mark Sweep GC needs to be used for Class Unloading (above)
"-Xms1024m"
; give JVM a decent heap size to start with
"-Xmx2048m"
; hard limit of 2GB so we stop hitting the 4GB container limit on CircleCI
"-XX:PermSize=64m"
; start with a little more PermGen space
"-XX:MaxPermSize=128m"
; a little more headroom for PermGen
"-XX:+CMSClassUnloadingEnabled"
; let Clojure's dynamically generated temporary classes be GC'ed from PermGen
"-XX:+UseConcMarkSweepGC"
]}
; Concurrent Mark Sweep GC needs to be used for Class Unloading (above)
:uberjar
{
:aot
:all
:prep-tasks
[
"npm"
"gulp"
"javac"
"compile"
]}})
This diff is collapsed.
Click to expand it.
test/metabase/api/result_test.clj
0 → 100644
+
54
−
0
View file @
0b58a477
(
ns
metabase.api.result-test
"Tests for /api/result endpoints."
(
:require
[
expectations
:refer
:all
]
[
korma.core
:refer
:all
]
[
metabase.db
:refer
:all
]
(
metabase.models
[
query-execution
:refer
[
QueryExecution
]])
[
metabase.api.query-test
:refer
[
create-query
]]
[
metabase.test.util
:refer
[
match-$
random-name
expect-eval-actual-first
]]
[
metabase.test-data
:refer
:all
]))
(
defn
create-and-execute-query
"Create a `Query`, run it + wait for it to finish, and return the resulting `QueryExecution`."
[]
(
let
[{
query-id
:id
}
(
create-query
)
query-execution
((
user->client
:rasta
)
:post
200
(
format
"query/%d"
query-id
))]
(
Thread/sleep
100
)
; Give it 100ms to finish
query-execution
))
;; ## GET /result/:id
;; Check that we can fetch the QueryResult object that gets created when we call POST /api/query/:id
(
expect-eval-actual-first
(
match-$
(
sel
:one
QueryExecution
(
order
:id
:DESC
))
{
:query_id
$
:raw_query
""
:result_rows
1
:finished_at
$
:started_at
$
:json_query
{
:native
{
:timezone
nil,
:query
"SELECT COUNT(*) FROM VENUES;"
}
:database
(
:id
@
test-db
)
:type
"native"
}
:status
"completed"
:id
$
:uuid
$
:row_count
1
:running_time
$
:version
1
})
(
let
[{
execution-id
:id
}
(
create-and-execute-query
)]
((
user->client
:rasta
)
:get
200
(
format
"result/%d"
execution-id
))))
;; ## GET /result/:id/response
;; Can we get the results of a QueryExecution?
(
expect-eval-actual-first
(
match-$
(
sel
:one
QueryExecution
(
order
:id
:DESC
))
{
:id
$
:uuid
$
:status
"completed"
:data
{
:columns
[
"count(*)"
]
:cols
[{
:base_type
"IntegerField"
,
:name
"count(*)"
}]
:rows
[[
100
]]}
:row_count
1
})
(
let
[{
execution-id
:id
}
(
create-and-execute-query
)]
((
user->client
:rasta
)
:get
200
(
format
"result/%d/response"
execution-id
))))
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