Created
November 25, 2023 14:51
-
-
Save johnpena/4623e8911b11e2f9fcce413a6d99c8bf to your computer and use it in GitHub Desktop.
kvtest.bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
function kvset { | |
curl -s "localhost:4000/set?$1=$2" > /dev/null | |
} | |
function kvget { | |
url="localhost:4000/get?key=$1" | |
curl -s "$url" | jq '.value?' | |
} | |
function kverr { | |
url="localhost:4000/get?key=$1" | |
curl -s "$url" | jq '.message?' | |
} | |
function kvtest { | |
got=$(kvget $1) | |
expected="\"$2\"" | |
[[ $got == $expected ]] && echo "PASS" || echo "FAIL" | |
} | |
kvset "foo" "bar" | |
kvget "foo" | |
kvtest "foo" "bar" | |
kvset "a" "b" | |
kvset "b" "c" | |
kvset "c" "d" | |
kvset "a" "a" | |
kvtest "a" "a" | |
kvtest "b" "c" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment