84 lines
3.1 KiB
Plaintext
84 lines
3.1 KiB
Plaintext
http = require "luajit-curl-helper.http"
|
|
|
|
index_title = "miti.sh · Catalin Constantin Mititiuc"
|
|
|
|
req = (url) ->
|
|
request = http.init url
|
|
st = request\perform!
|
|
error request\lastError! if not st
|
|
request
|
|
|
|
describe "test environment", ->
|
|
it "can't connect to the internet", ->
|
|
request = http.init "http://example.org"
|
|
assert.not_true request\perform!
|
|
assert.same request\lastError!, "Couldn't resolve host name"
|
|
|
|
describe "http://webdevcat.me", ->
|
|
it "permanently redirects to http://miti.sh", ->
|
|
request = req "http://webdevcat.me"
|
|
assert.same request\statusCode!, 301
|
|
assert.same request\statusMessage!, "Moved Permanently"
|
|
assert.same request\header!.Location, "http://miti.sh/"
|
|
|
|
describe "http://webdevcat.me/git", ->
|
|
it "permanently redirects to http://git.miti.sh/ccm/", ->
|
|
request = req "http://webdevcat.me/git"
|
|
assert.same request\header!.Location, "http://git.miti.sh/ccm/"
|
|
|
|
describe "http://webdevcat.me/git/", ->
|
|
it "permanently redirects to http://git.miti.sh", ->
|
|
request = req "http://webdevcat.me/git"
|
|
assert.same request\header!.Location, "http://git.miti.sh/ccm/"
|
|
|
|
describe "http://webdevcat.me/git/pandoc", ->
|
|
it "permanently redirects to http://git.miti.sh/ccm/pandoc", ->
|
|
request = req "http://webdevcat.me/git/pandoc"
|
|
assert.same request\header!.Location, "http://git.miti.sh/ccm/pandoc"
|
|
|
|
describe "http://webdevcat.me/apps/btroops", ->
|
|
it "permanently redirects to http://apps.miti.sh/btroops", ->
|
|
request = req "http://webdevcat.me/apps/btroops"
|
|
assert.same request\header!.Location, "http://apps.miti.sh/btroops"
|
|
|
|
describe "http://miti.sh", ->
|
|
it "sends /index.html", ->
|
|
request = req "http://miti.sh"
|
|
assert.same request\statusCode!, 200
|
|
assert.same request\statusMessage!, "OK"
|
|
assert.same request\body!\match("<title>(.*)</title>"), index_title
|
|
|
|
describe "http://miti.sh/index", ->
|
|
it "sends /index.html", ->
|
|
request = req "http://miti.sh/index"
|
|
assert.same request\statusCode!, 200
|
|
assert.same request\statusMessage!, "OK"
|
|
assert.same request\body!\match("<title>(.*)</title>"), index_title
|
|
|
|
describe "http://miti.sh/index.html", ->
|
|
it "sends /index.html", ->
|
|
request = req "http://miti.sh/index.html"
|
|
assert.same request\statusCode!, 200
|
|
assert.same request\statusMessage!, "OK"
|
|
assert.same request\body!\match("<title>(.*)</title>"), index_title
|
|
|
|
describe "http://miti.sh/posts/", ->
|
|
it "permanently redirects to http://miti.sh/posts", ->
|
|
request = req "http://miti.sh/posts/"
|
|
assert.same request\statusCode!, 301
|
|
assert.same request\statusMessage!, "Moved Permanently"
|
|
assert.same request\header!.Location, "http://miti.sh/posts"
|
|
|
|
describe "http://miti.sh/posts", ->
|
|
it "sends /posts/index.html", ->
|
|
request = req "http://miti.sh/posts"
|
|
assert.same request\statusCode!, 200
|
|
assert.same request\statusMessage!, "OK"
|
|
assert.same request\body!\match("<title>(.*)</title>"), "miti.sh · Posts"
|
|
|
|
describe "http://apps.miti.sh", ->
|
|
it "doesn't find it", ->
|
|
request = req "http://apps.miti.sh"
|
|
assert.same request\statusCode!, 404
|
|
assert.same request\statusMessage!, "Not Found"
|