mirror of
https://github.com/Start9Labs/registry.git
synced 2026-03-26 02:11:53 +00:00
more robust testing
This commit is contained in:
@@ -4,6 +4,8 @@ module Handler.AppSpec (spec) where
|
||||
|
||||
import Startlude
|
||||
import TestImport
|
||||
import Database.Persist.Sql
|
||||
import Model
|
||||
|
||||
spec :: Spec
|
||||
spec = do
|
||||
@@ -15,15 +17,29 @@ spec = do
|
||||
bodyContains "bitcoind"
|
||||
bodyContains "version: 0.18.1"
|
||||
statusIs 200
|
||||
describe "GET /apps/:appId" $
|
||||
describe "GET /apps/:appId with unknown version spec for bitcoin" $
|
||||
withApp $ it "fails to get unknown app" $ do
|
||||
request $ do
|
||||
setMethod "GET"
|
||||
setUrl ("/apps/bitcoind.s9pk?spec=0.18.2" :: Text)
|
||||
setUrl ("/apps/bitcoind.s9pk?spec=0.18.3" :: Text)
|
||||
statusIs 404
|
||||
describe "GET /apps/:appId" $
|
||||
withApp $ it "makes da records" $ do
|
||||
describe "GET /apps/:appId with existing version spec for bitcoin" $
|
||||
withApp $ it "creates app and metric records" $ do
|
||||
request $ do
|
||||
setMethod "GET"
|
||||
setUrl ("/apps/bitcoind.s9pk?spec=0.18.1" :: Text)
|
||||
statusIs 200
|
||||
statusIs 200
|
||||
apps <- runDBtest $ selectList [SAppAppId ==. "bitcoind"] []
|
||||
metrics <- runDBtest $ selectList [MetricEvent ==. "bitcoind"] []
|
||||
assertEq "app should exist" (length apps) 1
|
||||
assertEq "metric should exist" (length metrics) 1
|
||||
describe "GET /apps/:appId with existing version spec for cups" $
|
||||
withApp $ it "creates app and metric records" $ do
|
||||
request $ do
|
||||
setMethod "GET"
|
||||
setUrl ("/apps/cups.s9pk?spec=0.2.1" :: Text)
|
||||
statusIs 200
|
||||
apps <- runDBtest $ selectList [SAppAppId ==. "cups"] []
|
||||
metrics <- runDBtest $ selectList [MetricEvent ==. "cups"] []
|
||||
assertEq "app should exist" (length apps) 1
|
||||
assertEq "metric should exist" (length metrics) 1
|
||||
|
||||
Reference in New Issue
Block a user