use tagged JSON on android, update tests (#321)

This commit is contained in:
Evgeny Poberezkin 2022-02-16 23:24:48 +00:00 committed by GitHub
parent d743804b1d
commit dd256be4ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 27 additions and 24 deletions

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
<runningDeviceTargetSelectedWithDropDown>
<Target>
<type value="RUNNING_DEVICE_TARGET" />
<deviceKey>
<Key>
<type value="SERIAL_NUMBER" />
<value value="1C231FDF600FYG" />
</Key>
</deviceKey>
</Target>
</runningDeviceTargetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2022-02-16T17:42:43.145045Z" />
</component>
</project>

View File

@ -3,7 +3,7 @@ packages: .
source-repository-package
type: git
location: git://github.com/simplex-chat/simplexmq.git
tag: 9c4778b12920db632322be27c3faf74bc9db3676
tag: c1f5f9d8461e254c0c67c65de36f0860306b3d72
source-repository-package
type: git

View File

@ -1,5 +1,5 @@
{
"git://github.com/simplex-chat/simplexmq.git"."9c4778b12920db632322be27c3faf74bc9db3676" = "0vkqkg0nl1z0ccggj1bjqv1i57vijhmw4qfm2myv07z88ch8brg8";
"git://github.com/simplex-chat/simplexmq.git"."c1f5f9d8461e254c0c67c65de36f0860306b3d72" = "1qbj4xgg27qwm67187vkn87jggd3q47v4vylh915kbxw7npilalj";
"git://github.com/simplex-chat/aeson.git"."3eb66f9a68f103b5f1489382aad89f5712a64db7" = "0kilkx59fl6c3qy3kjczqvm8c3f4n3p0bdk9biyflf51ljnzp4yp";
"git://github.com/simplex-chat/haskell-terminal.git"."f708b00009b54890172068f168bf98508ffcd495" = "0zmq7lmfsk8m340g47g5963yba7i88n4afa6z93sg9px5jv1mijj";
"git://github.com/zw3rk/android-support.git"."3c3a5ab0b8b137a072c98d3d0937cbdc96918ddb" = "1r6jyxbim3dsvrmakqfyxbd6ms6miaghpbwyl0sr6dzwpgaprz97";

View File

@ -17,8 +17,8 @@ build-type: Simple
extra-source-files:
README.md
if (os(linux))
ghc-option: -DANDROID
if (os(darwin))
ghc-option: -DIOS
library
exposed-modules:

View File

@ -48,7 +48,7 @@ extra-deps:
# - simplexmq-1.0.0@sha256:34b2004728ae396e3ae449cd090ba7410781e2b3cefc59259915f4ca5daa9ea8,8561
# - ../simplexmq
- github: simplex-chat/simplexmq
commit: 9c4778b12920db632322be27c3faf74bc9db3676
commit: c1f5f9d8461e254c0c67c65de36f0860306b3d72
# - terminal-0.2.0.0@sha256:de6770ecaae3197c66ac1f0db5a80cf5a5b1d3b64a66a05b50f442de5ad39570,2977
- github: simplex-chat/aeson
commit: 3eb66f9a68f103b5f1489382aad89f5712a64db7

View File

@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE NamedFieldPuns #-}
module MobileTests where
@ -16,13 +17,32 @@ mobileTests = do
it "start new chat with existing user" testChatApi
noActiveUser :: String
#if defined(IOS)
noActiveUser = "{\"resp\":{\"chatCmdError\":{\"chatError\":{\"error\":{\"errorType\":{\"noActiveUser\":{}}}}}}}"
#else
noActiveUser = "{\"resp\":{\"type\":\"chatCmdError\",\"chatError\":{\"type\":\"error\",\"errorType\":{\"type\":\"noActiveUser\"}}}}"
#endif
activeUserExists :: String
#if defined(IOS)
activeUserExists = "{\"resp\":{\"chatCmdError\":{\"chatError\":{\"error\":{\"errorType\":{\"activeUserExists\":{}}}}}}}"
#else
activeUserExists = "{\"resp\":{\"type\":\"chatCmdError\",\"chatError\":{\"type\":\"error\",\"errorType\":{\"type\":\"activeUserExists\"}}}}"
#endif
activeUser :: String
#if defined(IOS)
activeUser = "{\"resp\":{\"activeUser\":{\"user\":{\"userId\":1,\"userContactId\":1,\"localDisplayName\":\"alice\",\"profile\":{\"displayName\":\"alice\",\"fullName\":\"Alice\"},\"activeUser\":true}}}}"
#else
activeUser = "{\"resp\":{\"type\":\"activeUser\",\"user\":{\"userId\":1,\"userContactId\":1,\"localDisplayName\":\"alice\",\"profile\":{\"displayName\":\"alice\",\"fullName\":\"Alice\"},\"activeUser\":true}}}"
#endif
chatStarted :: String
#if defined(IOS)
chatStarted = "{\"resp\":{\"chatStarted\":{}}}"
#else
chatStarted = "{\"resp\":{\"type\":\"chatStarted\"}}"
#endif
testChatApiNoUser :: IO ()
testChatApiNoUser = withTmpFiles $ do
@ -30,7 +50,7 @@ testChatApiNoUser = withTmpFiles $ do
chatSendCmd cc "/u" `shouldReturn` noActiveUser
chatSendCmd cc "/_start" `shouldReturn` noActiveUser
chatSendCmd cc "/u alice Alice" `shouldReturn` activeUser
chatSendCmd cc "/_start" `shouldReturn` "{\"resp\":{\"chatStarted\":{}}}"
chatSendCmd cc "/_start" `shouldReturn` chatStarted
testChatApi :: IO ()
testChatApi = withTmpFiles $ do
@ -40,4 +60,4 @@ testChatApi = withTmpFiles $ do
cc <- chatInit testDBPrefix
chatSendCmd cc "/u" `shouldReturn` activeUser
chatSendCmd cc "/u alice Alice" `shouldReturn` activeUserExists
chatSendCmd cc "/_start" `shouldReturn` "{\"resp\":{\"chatStarted\":{}}}"
chatSendCmd cc "/_start" `shouldReturn` chatStarted