mirror of
https://github.com/eliasstepanik/caddy-ingess.git
synced 2026-01-11 04:28:28 +00:00
38 lines
773 B
Go
38 lines
773 B
Go
package caddy
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/caddyserver/ingress/pkg/store"
|
|
)
|
|
|
|
func TestConvertToCaddyConfig(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
expectedConfigPath string
|
|
}{
|
|
{
|
|
name: "default",
|
|
expectedConfigPath: "./test_data/default.json",
|
|
},
|
|
}
|
|
for _, test := range tests {
|
|
t.Run(test.name, func(t *testing.T) {
|
|
cfg, err := Converter{}.ConvertToCaddyConfig(store.NewStore(store.Options{}, &store.PodInfo{}))
|
|
require.NoError(t, err)
|
|
|
|
cfgJson, err := json.Marshal(cfg)
|
|
require.NoError(t, err)
|
|
|
|
expectedCfg, err := os.ReadFile(test.expectedConfigPath)
|
|
require.NoError(t, err)
|
|
|
|
require.JSONEq(t, string(expectedCfg), string(cfgJson))
|
|
})
|
|
}
|
|
}
|