built database
This commit is contained in:
@@ -14,6 +14,7 @@ spec = describe "Mtlstats.Types" $ do
|
||||
pPointsSpec
|
||||
playerSpec
|
||||
goalieSpec
|
||||
databaseSpec
|
||||
|
||||
pPointsSpec :: Spec
|
||||
pPointsSpec = describe "pPoints" $ mapM_
|
||||
@@ -55,6 +56,17 @@ goalieSpec = describe "Goalie" $ do
|
||||
it "should encode" $
|
||||
decode (encode goalie) `shouldBe` Just goalie
|
||||
|
||||
databaseSpec :: Spec
|
||||
databaseSpec = describe "Database" $ do
|
||||
|
||||
describe "decode" $
|
||||
it "should decode" $
|
||||
decode dbJSON `shouldBe` Just db
|
||||
|
||||
describe "encode" $
|
||||
it "should encode" $
|
||||
decode (encode db) `shouldBe` Just db
|
||||
|
||||
player :: Player
|
||||
player = newPlayer 1 "Joe" "centre"
|
||||
& pYtd . psGoals .~ 2
|
||||
@@ -81,6 +93,11 @@ goalie = newGoalie 1 "Joe"
|
||||
& gLifetime . gsLosses .~ 14
|
||||
& gLifetime . gsTies .~ 15
|
||||
|
||||
db :: Database
|
||||
db = newDatabase
|
||||
& dbPlayers .~ [player]
|
||||
& dbGoalies .~ [goalie]
|
||||
|
||||
playerJSON :: ByteString
|
||||
playerJSON = [r|
|
||||
{ "number": 1
|
||||
@@ -121,3 +138,11 @@ goalieJSON = [r|
|
||||
, "ties": 15
|
||||
}
|
||||
}|]
|
||||
|
||||
dbJSON :: ByteString
|
||||
dbJSON = [r|
|
||||
{ "players":
|
||||
[ |] <> playerJSON <> [r| ]
|
||||
, "goalies":
|
||||
[ |] <> goalieJSON <> [r| ]
|
||||
}|]
|
||||
|
||||
Reference in New Issue
Block a user