fea: config: add tests

This commit is contained in:
Daniel Ding
2022-10-28 20:52:02 +08:00
parent a69383c919
commit 72d8316aaa
15 changed files with 209 additions and 228 deletions

18
pkg/config/switch_test.go Normal file
View File

@@ -0,0 +1,18 @@
package config
import (
"github.com/luscis/openlan/pkg/libol"
"github.com/stretchr/testify/assert"
"testing"
)
func TestSwitch(t *testing.T) {
sw := Switch{}
sw.Correct()
assert.Equal(t, libol.INFO, sw.Log.Verbose, "be the same.")
assert.Equal(t, "0.0.0.0:10002", sw.Listen, "be the same.")
assert.Equal(t, "0.0.0.0:10000", sw.Http.Listen, "be the same.")
sw.Listen = "192.168.1.0"
sw.Correct()
assert.Equal(t, "192.168.1.0:10002", sw.Listen, "be the same.")
}