Skip to content

Commit 60548ea

Browse files
committed
Add (failing) tests.
1 parent 6a098dd commit 60548ea

File tree

1 file changed

+40
-18
lines changed
  • services/galley/test/integration/API

1 file changed

+40
-18
lines changed

services/galley/test/integration/API/Teams.hs

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,37 +1458,59 @@ testUpdateTeam = do
14581458
g <- view tsGalley
14591459
c <- view tsCannon
14601460
(tid, owner, [member]) <- Util.createBindingTeamWithMembers 2
1461+
1462+
let doput :: LByteString -> Int -> TestM ()
1463+
doput u code =
1464+
put
1465+
( g
1466+
. paths ["teams", toByteString' tid]
1467+
. zUser owner
1468+
. zConn "conn"
1469+
. body (RequestBodyLBS u)
1470+
)
1471+
!!! const code
1472+
=== statusCode
1473+
14611474
let bad = object ["name" .= T.replicate 100 "too large"]
1462-
put
1463-
( g
1464-
. paths ["teams", toByteString' tid]
1465-
. zUser owner
1466-
. zConn "conn"
1467-
. json bad
1468-
)
1469-
!!! const 400
1470-
=== statusCode
1475+
doput (encode bad) 400
14711476
let u =
14721477
newTeamUpdateData
14731478
& nameUpdate .~ (Just $ unsafeRange "bar")
14741479
& iconUpdate .~ fromByteString "3-1-47de4580-ae51-4650-acbb-d10c028cb0ac"
14751480
& iconKeyUpdate .~ (Just $ unsafeRange "yyy")
14761481
& splashScreenUpdate .~ fromByteString "3-1-e1c89a56-882e-4694-bab3-c4f57803c57a"
1477-
WS.bracketR2 c owner member $ \(wsOwner, wsMember) -> do
1478-
put
1482+
1483+
do
1484+
WS.bracketR2 c owner member $ \(wsOwner, wsMember) -> do
1485+
doput (encode u) 200
1486+
checkTeamUpdateEvent tid u wsOwner
1487+
checkTeamUpdateEvent tid u wsMember
1488+
WS.assertNoEvent timeout [wsOwner, wsMember]
1489+
t <- Util.getTeam owner tid
1490+
liftIO $ assertEqual "teamSplashScreen" (t ^. teamSplashScreen) (fromByteString "3-1-e1c89a56-882e-4694-bab3-c4f57803c57a")
1491+
1492+
do
1493+
-- setting fields to `null` is the same as omitting the them from the update json record.
1494+
doput "{\"name\": null, \"icon\": null, \"icon_key\": null, \"splash_screen\": null}" 200
1495+
t <- Util.getTeam owner tid
1496+
liftIO $ assertEqual "teamSplashScreen" (t ^. teamSplashScreen) (fromByteString "3-1-e1c89a56-882e-4694-bab3-c4f57803c57a")
1497+
1498+
do
1499+
-- setting splash screen to `"default"` won't parse as an Id.
1500+
doput "{\"splash_screen\": \"default\"}" 400
1501+
1502+
do
1503+
-- use the `delete` end-point!
1504+
delete
14791505
( g
1480-
. paths ["teams", toByteString' tid]
1506+
. paths ["teams", toByteString' tid, "splash_screen"]
14811507
. zUser owner
14821508
. zConn "conn"
1483-
. json u
14841509
)
14851510
!!! const 200
14861511
=== statusCode
1487-
checkTeamUpdateEvent tid u wsOwner
1488-
checkTeamUpdateEvent tid u wsMember
1489-
WS.assertNoEvent timeout [wsOwner, wsMember]
1490-
t <- Util.getTeam owner tid
1491-
liftIO $ assertEqual "teamSplashScreen" (t ^. teamSplashScreen) (fromByteString "3-1-e1c89a56-882e-4694-bab3-c4f57803c57a")
1512+
t <- Util.getTeam owner tid
1513+
liftIO $ assertEqual "teamSplashScreen" (t ^. teamSplashScreen) Nothing
14921514

14931515
testTeamAddRemoveMemberAboveThresholdNoEvents :: HasCallStack => TestM ()
14941516
testTeamAddRemoveMemberAboveThresholdNoEvents = do

0 commit comments

Comments
 (0)