1civet = require "ci/test/civet"
2local curl = require "cURL"
3
4describe("civetweb basic", function()
5
6  setup(function()
7    civet.start()
8  end)
9
10  teardown(function()
11    civet.stop()
12  end)
13
14
15  it("should serve a simple get request", function()
16
17    local out = ""
18    function capture(str)
19      out = out .. str
20    end
21
22    local c = curl.easy()
23      :setopt_url('http://localhost:' .. civet.port .. "/")
24      :setopt_writefunction(capture)
25      :perform()
26    :close()
27
28    --print('rescode:' .. c.getinfo(curl.INFO_RESPONSE_CODE))
29
30    assert.are.equal('Index of', string.match(out, 'Index of'))
31    assert.are.equal('01_basic_test_dir', string.match(out, '01_basic_test_dir'))
32    assert.are.equal('01_basic_test_file', string.match(out, '01_basic_test_file'))
33  end)
34
35end)
36