2020-07-13 16:48:56 +00:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2020-11-21 17:08:41 +00:00
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2020-07-13 16:48:56 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestConfig_HttpServerHost2(t *testing.T) {
|
2020-07-13 18:25:47 +00:00
|
|
|
c := NewConfig(CliTestContext())
|
|
|
|
|
2020-12-18 08:11:42 +00:00
|
|
|
assert.Equal(t, "0.0.0.0", c.HttpHost())
|
2020-12-18 19:42:12 +00:00
|
|
|
c.options.HttpHost = "test"
|
2020-12-18 08:11:42 +00:00
|
|
|
assert.Equal(t, "test", c.HttpHost())
|
2020-07-13 16:48:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestConfig_HttpServerPort2(t *testing.T) {
|
2020-07-13 18:25:47 +00:00
|
|
|
c := NewConfig(CliTestContext())
|
|
|
|
|
2020-12-18 08:11:42 +00:00
|
|
|
assert.Equal(t, int(2342), c.HttpPort())
|
2020-12-18 19:42:12 +00:00
|
|
|
c.options.HttpPort = int(1234)
|
2020-12-18 08:11:42 +00:00
|
|
|
assert.Equal(t, int(1234), c.HttpPort())
|
2020-07-13 16:48:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestConfig_HttpServerMode2(t *testing.T) {
|
2020-07-13 18:25:47 +00:00
|
|
|
c := NewConfig(CliTestContext())
|
|
|
|
|
2020-12-18 08:11:42 +00:00
|
|
|
assert.Equal(t, "release", c.HttpMode())
|
2020-12-18 19:42:12 +00:00
|
|
|
c.options.Debug = true
|
2020-12-18 08:11:42 +00:00
|
|
|
assert.Equal(t, "debug", c.HttpMode())
|
2020-12-18 19:42:12 +00:00
|
|
|
c.options.HttpMode = "test"
|
2020-12-18 08:11:42 +00:00
|
|
|
assert.Equal(t, "test", c.HttpMode())
|
2020-07-13 16:48:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestConfig_TemplateName(t *testing.T) {
|
2020-07-13 18:25:47 +00:00
|
|
|
c := NewConfig(CliTestContext())
|
2020-10-08 06:52:03 +00:00
|
|
|
c.initSettings()
|
2020-07-13 18:25:47 +00:00
|
|
|
|
2020-07-13 16:48:56 +00:00
|
|
|
assert.Equal(t, "index.tmpl", c.TemplateName())
|
|
|
|
c.settings.Templates.Default = "rainbow.tmpl"
|
|
|
|
assert.Equal(t, "rainbow.tmpl", c.TemplateName())
|
2020-07-13 17:25:27 +00:00
|
|
|
c.settings.Templates.Default = "xxx"
|
|
|
|
assert.Equal(t, "index.tmpl", c.TemplateName())
|
|
|
|
|
2020-07-13 16:48:56 +00:00
|
|
|
}
|
2021-02-22 10:07:00 +00:00
|
|
|
|
|
|
|
func TestConfig_HttpCompression(t *testing.T) {
|
|
|
|
c := NewConfig(CliTestContext())
|
|
|
|
|
|
|
|
assert.Equal(t, "", c.HttpCompression())
|
|
|
|
}
|