File tree 1 file changed +33
-7
lines changed
1 file changed +33
-7
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package caddy
2
2
3
3
import (
4
4
"errors"
5
+ "fmt"
5
6
"testing"
6
7
7
8
"github.com/scmmishra/slick-deploy/internal/config"
@@ -41,20 +42,45 @@ func TestConvertToCaddyfile(t *testing.T) {
41
42
{
42
43
Path : "/" ,
43
44
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
+ } ,
50
51
},
51
52
},
52
53
},
53
54
},
54
55
}
55
56
56
57
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 \n localhost {\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
+ `
58
84
assert .Equal (t , expectedCaddyfile , caddyfile )
59
85
}
60
86
You can’t perform that action at this time.
0 commit comments