Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
darkweak committed Nov 12, 2022
1 parent 0bc4aab commit ca40ee6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions fixtures/alt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<esi:include src="http://invalid.do.main" alt=http://domain.com:9080/alt-esi-include/>
2 changes: 1 addition & 1 deletion fixtures/include
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<esi:include src="http://domain.com/chained-esi-include-1" alt=http://domain.com/alt-esi-include/>
<esi:include src="http://domain.com:9080/chained-esi-include-1" alt=http://domain.com:9080/alt-esi-include/>
23 changes: 23 additions & 0 deletions middleware/caddy/esi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,26 @@ func TestFullHTML(t *testing.T) {

_, _ = tester.AssertGetResponse(`http://domain.com:9080/full.html`, http.StatusOK, expectedOutput)
}

func TestInclude(t *testing.T) {
tester := caddytest.NewTester(t)
tester.InitServer(loadCaddyfile(), "caddyfile")

_, _ = tester.AssertGetResponse(`http://domain.com:9080/include`, http.StatusOK, "<h1>CHAINED 2</h1>")
}

func TestIncludeAlt(t *testing.T) {
tester := caddytest.NewTester(t)
tester.InitServer(loadCaddyfile(), "caddyfile")

_, _ = tester.AssertGetResponse(`http://domain.com:9080/alt`, http.StatusOK, "<h1>ALTERNATE ESI INCLUDE</h1>")
}

func TestEscape(t *testing.T) {
tester := caddytest.NewTester(t)
tester.InitServer(loadCaddyfile(), "caddyfile")

_, _ = tester.AssertGetResponse(`http://domain.com:9080/escape`, http.StatusOK, `
<p><esi:vars>Hello, $(HTTP_COOKIE{name})!</esi:vars></p>
`)
}

0 comments on commit ca40ee6

Please sign in to comment.