mirror of
https://github.com/Start9Labs/registry.git
synced 2026-03-30 19:54:47 +00:00
refactor test suite for model and api changes, adding tests for fetched versions via index endpoint
This commit is contained in:
committed by
Keagan McClelland
parent
dc48a33ff6
commit
1fa87724d0
@@ -2,7 +2,8 @@
|
||||
|
||||
module Handler.MarketplaceSpec
|
||||
( spec
|
||||
) where
|
||||
)
|
||||
where
|
||||
|
||||
import Data.Maybe
|
||||
import Database.Persist.Sql
|
||||
@@ -14,117 +15,41 @@ import Conduit ( (.|)
|
||||
)
|
||||
import Database.Marketplace
|
||||
import Lib.Types.Category
|
||||
import Lib.Types.Emver
|
||||
import Model
|
||||
import TestImport
|
||||
import Seed
|
||||
|
||||
spec :: Spec
|
||||
spec = do
|
||||
describe "searchServices with category" $ withApp $ it "should filter services with featured category" $ do
|
||||
time <- liftIO getCurrentTime
|
||||
btc <- runDBtest $ insert $ SApp time
|
||||
(Just time)
|
||||
"Bitcoin Core"
|
||||
"bitcoind"
|
||||
"short desc bitcoin"
|
||||
"long desc bitcoin"
|
||||
"png"
|
||||
lnd <- runDBtest $ insert $ SApp time
|
||||
(Just time)
|
||||
"Lightning Network Daemon"
|
||||
"lnd"
|
||||
"short desc lnd"
|
||||
"long desc lnd"
|
||||
"png"
|
||||
featuredCat <- runDBtest $ insert $ Category time FEATURED Nothing "desc" 0
|
||||
btcCat <- runDBtest $ insert $ Category time BITCOIN Nothing "desc" 0
|
||||
lnCat <- runDBtest $ insert $ Category time LIGHTNING Nothing "desc" 0
|
||||
_ <- runDBtest $ insert_ $ ServiceCategory time btc featuredCat "bitcoin" FEATURED Nothing
|
||||
_ <- runDBtest $ insert_ $ ServiceCategory time lnd lnCat "lnd" LIGHTNING Nothing
|
||||
_ <- runDBtest $ insert_ $ ServiceCategory time lnd btcCat "lnd" BITCOIN Nothing
|
||||
_ <- runDBtest $ insert_ $ ServiceCategory time btc btcCat "bitcon" BITCOIN Nothing
|
||||
apps <- runDBtest $ runConduit $ searchServices (Just FEATURED) "" .| sinkList
|
||||
assertEq "should exist" (length apps) 1
|
||||
let app' = fromJust $ head apps
|
||||
assertEq "should be bitcoin" (sAppTitle $ entityVal app') "Bitcoin Core"
|
||||
_ <- seedBitcoinLndStack
|
||||
packages <- runDBtest $ runConduit $ searchServices (Just FEATURED) "" .| sinkList
|
||||
assertEq "should exist" (length packages) 1
|
||||
let pkg = fromJust $ head packages
|
||||
assertEq "should be bitcoin" (pkgRecordTitle $ entityVal pkg) "Bitcoin Core"
|
||||
describe "searchServices with category" $ withApp $ it "should filter services with bitcoin category" $ do
|
||||
time <- liftIO getCurrentTime
|
||||
btc <- runDBtest $ insert $ SApp time
|
||||
(Just time)
|
||||
"Bitcoin Core"
|
||||
"bitcoind"
|
||||
"short desc bitcoin"
|
||||
"long desc bitcoin"
|
||||
"png"
|
||||
lnd <- runDBtest $ insert $ SApp time
|
||||
(Just time)
|
||||
"Lightning Network Daemon"
|
||||
"lnd"
|
||||
"short desc lnd"
|
||||
"long desc lnd"
|
||||
"png"
|
||||
featuredCat <- runDBtest $ insert $ Category time FEATURED Nothing "desc" 0
|
||||
btcCat <- runDBtest $ insert $ Category time BITCOIN Nothing "desc" 0
|
||||
lnCat <- runDBtest $ insert $ Category time LIGHTNING Nothing "desc" 0
|
||||
_ <- runDBtest $ insert_ $ ServiceCategory time btc featuredCat "bitcoind" FEATURED Nothing
|
||||
_ <- runDBtest $ insert_ $ ServiceCategory time lnd lnCat "lnd" LIGHTNING Nothing
|
||||
_ <- runDBtest $ insert_ $ ServiceCategory time lnd btcCat "lnd" BITCOIN Nothing
|
||||
_ <- runDBtest $ insert_ $ ServiceCategory time btc btcCat "bitcoind" BITCOIN Nothing
|
||||
apps <- runDBtest $ runConduit $ searchServices (Just BITCOIN) "" .| sinkList
|
||||
assertEq "should exist" (length apps) 2
|
||||
_ <- seedBitcoinLndStack
|
||||
packages <- runDBtest $ runConduit $ searchServices (Just BITCOIN) "" .| sinkList
|
||||
assertEq "should exist" (length packages) 3
|
||||
describe "searchServices with fuzzy query"
|
||||
$ withApp
|
||||
$ it "runs search service with fuzzy text in long description"
|
||||
$ it "runs search service with fuzzy text in long description and no category"
|
||||
$ do
|
||||
time <- liftIO getCurrentTime
|
||||
app1 <- runDBtest $ insert $ SApp time
|
||||
(Just time)
|
||||
"Bitcoin Core"
|
||||
"bitcoind"
|
||||
"short desc"
|
||||
"long desc"
|
||||
"png"
|
||||
app2 <- runDBtest $ insert $ SApp time
|
||||
(Just time)
|
||||
"Lightning Network Daemon"
|
||||
"lnd"
|
||||
"short desc"
|
||||
"lightning long desc"
|
||||
"png"
|
||||
cate <- runDBtest $ insert $ Category time FEATURED Nothing "desc" 0
|
||||
_ <- runDBtest $ insert_ $ ServiceCategory time app1 cate "bitcoind" FEATURED Nothing
|
||||
_ <- runDBtest $ insert_ $ ServiceCategory time app2 cate "lnd" FEATURED Nothing
|
||||
apps <- runDBtest $ runConduit $ searchServices (Just FEATURED) "lightning" .| sinkList
|
||||
assertEq "should exist" (length apps) 1
|
||||
let app' = fromJust $ head apps
|
||||
print app'
|
||||
_ <- seedBitcoinLndStack
|
||||
packages <- runDBtest $ runConduit $ searchServices Nothing "lightning" .| sinkList
|
||||
assertEq "should exist" (length packages) 1
|
||||
let pkg = fromJust $ head packages
|
||||
print pkg
|
||||
describe "searchServices with fuzzy query"
|
||||
$ withApp
|
||||
$ it "runs search service with fuzzy text in long description and bitcoin category"
|
||||
$ do
|
||||
_ <- seedBitcoinLndStack
|
||||
packages <- runDBtest $ runConduit $ searchServices (Just BITCOIN) "proxy" .| sinkList
|
||||
assertEq "should exist" (length packages) 1
|
||||
let pkg = fromJust $ head packages
|
||||
print pkg
|
||||
describe "searchServices with any category" $ withApp $ it "runs search service for any category" $ do
|
||||
time <- liftIO getCurrentTime
|
||||
btc <- runDBtest $ insert $ SApp time
|
||||
(Just time)
|
||||
"Bitcoin Core"
|
||||
"bitcoind"
|
||||
"short desc bitcoin"
|
||||
"long desc bitcoin"
|
||||
"png"
|
||||
print btc
|
||||
_ <- runDBtest $ insert $ SVersion time (Just time) btc "0.19.0" "notes" Any Any Nothing
|
||||
_ <- runDBtest $ insert $ SVersion time (Just time) btc "0.20.0" "notes" Any Any Nothing
|
||||
lnd <- runDBtest $ insert $ SApp time
|
||||
(Just time)
|
||||
"Lightning Network Daemon"
|
||||
"lnd"
|
||||
"short desc lnd"
|
||||
"long desc lnd"
|
||||
"png"
|
||||
_ <- runDBtest $ insert $ SVersion time (Just time) lnd "0.18.0" "notes" Any Any Nothing
|
||||
_ <- runDBtest $ insert $ SVersion time (Just time) lnd "0.17.0" "notes" Any Any Nothing
|
||||
featuredCat <- runDBtest $ insert $ Category time FEATURED Nothing "desc" 0
|
||||
btcCat <- runDBtest $ insert $ Category time BITCOIN Nothing "desc" 0
|
||||
lnCat <- runDBtest $ insert $ Category time LIGHTNING Nothing "desc" 0
|
||||
_ <- runDBtest $ insert_ $ ServiceCategory time btc featuredCat "bitcoin" FEATURED Nothing
|
||||
_ <- runDBtest $ insert_ $ ServiceCategory time lnd lnCat "lnd" LIGHTNING Nothing
|
||||
_ <- runDBtest $ insert_ $ ServiceCategory time lnd btcCat "lnd" BITCOIN Nothing
|
||||
_ <- runDBtest $ insert_ $ ServiceCategory time btc btcCat "bitcon" BITCOIN Nothing
|
||||
apps <- runDBtest $ runConduit $ searchServices Nothing "" .| sinkList
|
||||
assertEq "should exist" (length apps) 2
|
||||
_ <- seedBitcoinLndStack
|
||||
packages <- runDBtest $ runConduit $ searchServices Nothing "" .| sinkList
|
||||
assertEq "should exist" (length packages) 3
|
||||
|
||||
Reference in New Issue
Block a user