Skip to content

Commit c44ae9f

Browse files
committed
test: new caddy
1 parent b44dcda commit c44ae9f

File tree

1 file changed

+33
-7
lines changed

1 file changed

+33
-7
lines changed

internal/caddy/caddy_test.go

+33-7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package caddy
22

33
import (
44
"errors"
5+
"fmt"
56
"testing"
67

78
"github.com/scmmishra/slick-deploy/internal/config"
@@ -41,20 +42,45 @@ func TestConvertToCaddyfile(t *testing.T) {
4142
{
4243
Path: "/",
4344
To: "http://localhost:{port}",
44-
},
45-
},
46-
HeaderUp: []config.HeaderUp{
47-
{
48-
Name: "X-Real-IP",
49-
Value: "{http.request.remote.host}",
45+
HeaderUp: []config.HeaderUp{
46+
{
47+
Name: "X-Real-IP",
48+
Value: "{http.request.remote.host}",
49+
},
50+
},
5051
},
5152
},
5253
},
5354
},
5455
}
5556

5657
caddyfile := ConvertToCaddyfile(caddyCfg, 8080)
57-
expectedCaddyfile := "{\n email [email protected]\n on_demand_tls {\n ask https://acme.example.com/directory\n interval 3600\n burst 13\n }\n}\n\nlocalhost {\n tls {\n internal\n }\n header_up X-Real-IP {http.request.remote.host}\n handle / {\n root * /usr/share/caddy\n }\n handle /healthz {\n respond \"OK\" 200\n }\n reverse_proxy / http://localhost:8080\n}\n\n"
58+
fmt.Println(caddyfile)
59+
expectedCaddyfile := `{
60+
61+
on_demand_tls {
62+
ask https://acme.example.com/directory
63+
interval 3600
64+
burst 13
65+
}
66+
}
67+
68+
localhost {
69+
tls {
70+
internal
71+
}
72+
handle / {
73+
root * /usr/share/caddy
74+
}
75+
handle /healthz {
76+
respond "OK" 200
77+
}
78+
reverse_proxy / http://localhost:8080 {
79+
header_up X-Real-IP {http.request.remote.host}
80+
}
81+
}
82+
83+
`
5884
assert.Equal(t, expectedCaddyfile, caddyfile)
5985
}
6086

0 commit comments

Comments
 (0)