Skip to content

Commit

Permalink
Merge pull request #12 from loladiro/tests
Browse files Browse the repository at this point in the history
basic tests, fixes dirk#7
  • Loading branch information
Keno committed Jan 30, 2014
2 parents 444c775 + e3dd3a3 commit 429552b
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
language: cpp
compiler:
- gcc
notifications:
email: false
before_install:
- sudo add-apt-repository ppa:staticfloat/julia-deps -y
- sudo add-apt-repository ppa:staticfloat/julianightlies -y
- sudo apt-get update -qq -y
- sudo apt-get install git libpcre3-dev julia -y
- git config --global user.name "Travis User"
- git config --global user.email "[email protected]"
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
script:
- julia -e 'versioninfo(); Pkg.init(); Pkg.clone(pwd())'
- julia ./test/runtests.jl
65 changes: 65 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@

using Requests
using JSON
using Base.Test


# simple calls, no headers, data or query params -------

@test get("http://httpbin.org/get").status === 200
@test post("http://httpbin.org/post").status === 200
@test put("http://httpbin.org/put").status === 200
@test delete("http://httpbin.org/delete").status === 200
@test options("http://httpbin.org/get").status === 200


# check query params -------

data = JSON.parse(get("http://httpbin.org/get"; query = {"key1" => "value1"}).data)
@test data["args"]["key1"] == "value1"

data = JSON.parse(post("http://httpbin.org/post"; query = {"key1" => "value1",
"key2" => "value2" }).data)
@test data["args"]["key1"] == "value1"
@test data["args"]["key2"] == "value2"

data = JSON.parse(put("http://httpbin.org/put"; query = {"key1" => "value1",
"key2" => "value2",
"key3" => 3 }).data)
@test data["args"]["key1"] == "value1"
@test data["args"]["key2"] == "value2"
@test data["args"]["key3"] == "3"

data = JSON.parse(delete("http://httpbin.org/delete"; query = {"key1" => "value1",
"key4" => 4.01 }).data)
@test data["args"]["key1"] == "value1"
@test data["args"]["key4"] == "4.01"

data = JSON.parse(options("http://httpbin.org/get"; query = {"key1" => "value1",
"key2" => "value2",
"key3" => 3,
"key4" => 4.01 }).data)
@test data == nothing


#check data -------

data = JSON.parse(post("http://httpbin.org/post"; data = {"key1" => "value1",
"key2" => "value2" }).data)
@test data["json"]["key1"] == "value1"
@test data["json"]["key2"] == "value2"

data = JSON.parse(put("http://httpbin.org/put"; data = {"key1" => "value1",
"key2" => "value2",
"key3" => 3 }).data)
@test data["json"]["key1"] == "value1"
@test data["json"]["key2"] == "value2"
@test data["json"]["key3"] == 3

data = JSON.parse(delete("http://httpbin.org/delete"; data = {"key1" => "value1",
"key4" => 4.01 }).data)
@test data["json"]["key1"] == "value1"
@test data["json"]["key4"] == 4.01



0 comments on commit 429552b

Please sign in to comment.