Files
livekit-3d/pkg/config/config_test.go
T
David Zhao 9c8d9fca0c Enforce config fields, fail on unknown keys (#1051)
If/when users have a typo or misindentation in their config file, we
would have silently failed to assign the value and moved on.

With this change it'll error out, alerting user of the problem.
2022-09-28 22:13:52 -07:00

33 lines
709 B
Go

package config
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestConfig_UnmarshalKeys(t *testing.T) {
conf, err := NewConfig("", nil)
require.NoError(t, err)
require.NoError(t, conf.unmarshalKeys("key1: secret1"))
require.Equal(t, "secret1", conf.Keys["key1"])
}
func TestConfig_DefaultsKept(t *testing.T) {
const content = `room:
empty_timeout: 10`
conf, err := NewConfig(content, nil)
require.NoError(t, err)
require.Equal(t, true, conf.Room.AutoCreate)
require.Equal(t, uint32(10), conf.Room.EmptyTimeout)
}
func TestConfig_UnknownKeys(t *testing.T) {
const content = `unknown: 10
room:
empty_timeout: 10`
_, err := NewConfig(content, nil)
require.Error(t, err)
}