add test for addSndQueue

This commit is contained in:
Efim Poberezkin
2021-01-06 22:35:04 +04:00
parent 61092e8371
commit 94d0be5d27
3 changed files with 17 additions and 2 deletions
@@ -294,6 +294,7 @@ instance MonadUnliftIO m => MonadAgentStore SQLiteStore m where
>>= return . fmap (SomeConn SCSend . SendConnection connAlias)
Right (_, _) -> return $ Left SEBadConn
-- TODO make transactional
addSndQueue :: SQLiteStore -> ConnAlias -> SendQueue -> m (Either StoreError (Connection CDuplex))
addSndQueue st connAlias sndQueue = do
serverId <- upsertServer st (server (sndQueue :: SendQueue))
+15 -1
View File
@@ -27,7 +27,7 @@ storeTests = withStore do
testCreateRcvConn :: SpecWith SQLiteStore
testCreateRcvConn = do
it "should create and get receive connection" $ \store -> do
it "should create receive connection and add send queue" $ \store -> do
let rcvQueue =
ReceiveQueue
{ server = SMPServer "smp.simplex.im" (Just "5223") (Just "1234"),
@@ -44,6 +44,20 @@ testCreateRcvConn = do
`shouldReturn` Right (ReceiveConnection "1" rcvQueue)
getConn store "1"
`shouldReturn` Right (SomeConn SCReceive $ ReceiveConnection "1" rcvQueue)
let sndQueue =
SendQueue
{ server = SMPServer "smp.simplex.im" (Just "5223") (Just "1234"),
sndId = "1234",
sndPrivateKey = "abcd",
encryptKey = "dcba",
signKey = "edcb",
status = New,
ackMode = AckMode On
}
addSndQueue store "1" sndQueue
`shouldReturn` Right (DuplexConnection "1" rcvQueue sndQueue)
getConn store "1"
`shouldReturn` Right (SomeConn SCDuplex $ DuplexConnection "1" rcvQueue sndQueue)
testCreateSndConn :: SpecWith SQLiteStore
testCreateSndConn = do
+1 -1
View File
@@ -6,5 +6,5 @@ import Test.Hspec
main :: IO ()
main = hspec do
describe "SMP server" serverTests
-- describe "SMP server" serverTests
describe "SMP client agent" agentTests