Files
cunicu/pkg/config/map_test.go
Steffen Vogel 3bee839348 fix: Update copyright years
Signed-off-by: Steffen Vogel <post@steffenvogel.de>
2025-01-01 22:45:39 +01:00

65 lines
1.2 KiB
Go

// SPDX-FileCopyrightText: 2023-2025 Steffen Vogel <post@steffenvogel.de>
// SPDX-License-Identifier: Apache-2.0
package config_test
import (
"time"
"github.com/pion/ice/v4"
"cunicu.li/cunicu/pkg/config"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = It("map", func() {
s := config.Settings{
WatchInterval: 5 * time.Second,
Interfaces: map[string]config.InterfaceSettings{
"wg0": {
ICE: config.ICESettings{
NetworkTypes: []ice.NetworkType{
ice.NetworkTypeTCP4,
ice.NetworkTypeTCP6,
},
},
HostName: "test",
},
},
DefaultInterfaceSettings: config.InterfaceSettings{
HostName: "test2",
Hooks: []config.HookSetting{
&config.ExecHookSetting{
BaseHookSetting: config.BaseHookSetting{
Type: "exec",
},
Command: "dummy",
Env: map[string]string{
"ENV1": "value1",
},
},
},
},
}
m := config.Map(s, "koanf")
Expect(m).To(Equal(map[string]any{
"watch_interval": "5s",
"interfaces": map[string]any{
"wg0": map[string]any{
"ice": map[string]any{
"network_types": []any{"tcp4", "tcp6"},
},
"hostname": "test",
},
},
"hooks": []any{
s.DefaultInterfaceSettings.Hooks[0],
},
"hostname": "test2",
}))
})