mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 19:13:34 +00:00
chore: refactor Caddyfile generator to accept a validator
This commit is contained in:
@@ -8,10 +8,10 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestGenerateCaddyfile(t *testing.T) {
|
||||
func TestCaddyfileGenerator(t *testing.T) {
|
||||
caddyfileHeader := `http:// {
|
||||
handle /.uncloud-verify {
|
||||
respond "verification-response-body" 200
|
||||
respond "test-machine-id" 200
|
||||
}
|
||||
log
|
||||
}
|
||||
@@ -24,6 +24,10 @@ func TestGenerateCaddyfile(t *testing.T) {
|
||||
}
|
||||
`
|
||||
|
||||
generator := &CaddyfileGenerator{
|
||||
MachineID: "test-machine-id",
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
containers []api.ServiceContainer
|
||||
@@ -182,7 +186,7 @@ http://app.example.com {
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
config, err := GenerateCaddyfile(tt.containers, "verification-response-body")
|
||||
config, err := generator.Generate(tt.containers)
|
||||
|
||||
if tt.wantErr {
|
||||
assert.Error(t, err)
|
||||
|
||||
Reference in New Issue
Block a user