Added cgi.readData. Add test for cgi module. (#9645)
Added cgi.readData. Add test for cgi module.
This commit is contained in:
parent
c50a04adc5
commit
3f3aee4078
1 changed files with 23 additions and 0 deletions
23
tests/stdlib/tcgi.nim
Normal file
23
tests/stdlib/tcgi.nim
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
discard """
|
||||||
|
action: run
|
||||||
|
file: tcgi.nim
|
||||||
|
output: "[Suite] Test cgi module"
|
||||||
|
"""
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
import cgi, strtabs
|
||||||
|
|
||||||
|
suite "Test cgi module":
|
||||||
|
const queryString = "foo=bar&фу=бар&checked=✓&list=1,2,3&with_space=text%20with%20space"
|
||||||
|
|
||||||
|
test "test query parsing with readData":
|
||||||
|
let parsedQuery = readData(queryString)
|
||||||
|
|
||||||
|
check parsedQuery["foo"] == "bar"
|
||||||
|
check parsedQuery["фу"] == "бар"
|
||||||
|
check parsedQuery["checked"] == "✓"
|
||||||
|
check parsedQuery["list"] == "1,2,3"
|
||||||
|
check parsedQuery["with_space"] == "text with space"
|
||||||
|
|
||||||
|
expect KeyError:
|
||||||
|
discard parsedQuery["not_existing_key"]
|
||||||
Loading…
Add table
Add a link
Reference in a new issue