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