mirror of
https://github.com/bsima/haskell-urbit-api.git
synced 2024-08-17 22:10:55 +03:00
test: add uid
This commit is contained in:
parent
d60f5b7168
commit
ffa7e5d644
4
login.sh
Executable file
4
login.sh
Executable file
@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
PORT=${1:-8080}
|
||||
curl -v "http://localhost:${PORT}/~/login" \
|
||||
--data-raw 'password=lidlut-tabwed-pillex-ridrup&redirect=%2F' \
|
11
test.hs
11
test.hs
@ -8,11 +8,14 @@ import Control.Exception (SomeException (..), try)
|
||||
import Control.Lens ((^?))
|
||||
import Data.Aeson (KeyValue ((.=)))
|
||||
import qualified Data.Aeson as Aeson
|
||||
import qualified Data.Char as Char
|
||||
import Data.Maybe (isJust)
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text as Text
|
||||
import qualified Data.Text.IO as Text.IO
|
||||
import qualified Network.Wreq as Wreq
|
||||
import qualified Numeric
|
||||
import qualified System.Random as Random
|
||||
import Urbit.Airlock
|
||||
|
||||
main :: IO ()
|
||||
@ -26,6 +29,7 @@ main = do
|
||||
|
||||
testing "poke ship" $
|
||||
isJust <$> do
|
||||
n <- Random.randomRIO (0, 100)
|
||||
r <-
|
||||
poke ship "zod" "chat-hook" "json" $
|
||||
Aeson.object
|
||||
@ -34,10 +38,10 @@ main = do
|
||||
[ "path" .= Text.pack "/~/~zod/mc",
|
||||
"envelope"
|
||||
.= Aeson.object
|
||||
[ "uid" .= Text.pack "FIXME",
|
||||
[ "uid" .= (Text.pack $ base32 n),
|
||||
"number" .= lastEventId ship,
|
||||
"author" .= Text.pack "~zod",
|
||||
"when" .= Text.pack "FIXME", -- int(time.time() * 1000)
|
||||
"when" .= Text.pack "1602118786225.497", -- int(time.time() * 1000)
|
||||
"letter" .= Aeson.object ["text" .= Text.pack "hello world!"]
|
||||
]
|
||||
]
|
||||
@ -73,6 +77,9 @@ testing description f =
|
||||
Right True ->
|
||||
Text.IO.putStrLn $ "PASS: " <> description
|
||||
|
||||
base32 :: Integer -> String
|
||||
base32 n = Numeric.showIntAtBase 32 Char.intToDigit n ""
|
||||
|
||||
{-
|
||||
s = baseconvert.base(random.getrandbits(128), 10, 32, string=True).lower()
|
||||
uid = '0v' + '.'.join(s[i:i+5] for i in range(0, len(s), 5))[::-1]
|
||||
|
Loading…
Reference in New Issue
Block a user