Files
openlan/pkg/config/point_test.go
2022-10-28 20:52:02 +08:00

41 lines
962 B
Go

package config
import (
"fmt"
"github.com/luscis/openlan/pkg/libol"
"github.com/stretchr/testify/assert"
"os"
"testing"
)
func TestPointFlags(t *testing.T) {
ap := Point{}
os.Args = []string{
"app",
"-conf", "/etc/openlan/fake.json",
"-terminal", "off",
"-alias", "fake",
}
ap.Parse()
fmt.Println(ap)
assert.Equal(t, "fake", ap.Alias, "be the same.")
assert.Equal(t, "/etc/openlan/fake.json", ap.SaveFile, "be the same.")
assert.Equal(t, "off", ap.Terminal, "be the same.")
}
func TestPoint(t *testing.T) {
ap := Point{
Username: "user0@fake",
}
ap.Correct()
assert.Equal(t, libol.INFO, ap.Log.Verbose, "be the same.")
assert.Equal(t, "tcp", ap.Protocol, "be the same.")
assert.Equal(t, "", ap.Crypt.Algo, "be the same.")
assert.Equal(t, "fake", ap.Network, "be the same.")
assert.Equal(t, "on", ap.Terminal, "be the same.")
ap.Crypt.Secret = "fake-pass"
ap.Correct()
assert.Equal(t, "xor", ap.Crypt.Algo, "be the same.")
}