Skip to content

Commit

Permalink
Fix config tests
Browse files Browse the repository at this point in the history
  • Loading branch information
logic committed Feb 23, 2017
1 parent d626c23 commit 2c914f0
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,32 @@ import (
)

func TestConfigListenAddress(t *testing.T) {
if _, err := LoadConfig(strings.NewReader("Tokens = [\"a\", \"b\"]\n")); err != nil {
var c Configuration
if err := LoadConfig(&c, strings.NewReader("Tokens = [\"a\", \"b\"]\n")); err != nil {
t.Error("Error parsing TOML configuration:", err)
}
}

func TestConfigTokens(t *testing.T) {
if _, err := LoadConfig(strings.NewReader("ListenAddress = \"1.2.3.4\"\n")); err != nil {
var c Configuration
if err := LoadConfig(&c, strings.NewReader("ListenAddress = \"1.2.3.4\"\n")); err != nil {
t.Error("Error parsing TOML configuration:", err)
}
}

func TestConfigAsyncResponse(t *testing.T) {
if _, err := LoadConfig(strings.NewReader("AsyncResponse = true\n")); err != nil {
var c Configuration
if err := LoadConfig(&c, strings.NewReader("AsyncResponse = true\n")); err != nil {
t.Error("Error parsing TOML configuration:", err)
}
}

func TestConfigHTTPClientTimeout(t *testing.T) {
config, err := LoadConfig(strings.NewReader("HTTPClientTimeout = 10\n"))
if err != nil {
var c Configuration
if err := LoadConfig(&c, strings.NewReader("HTTPClientTimeout = 10\n")); err != nil {
t.Error("Error parsing TOML configuration:", err)
}
if config.HTTPClientTimeout != 10*time.Second {
t.Errorf("Timeout incorrectly converted: 10 -> %d", config.HTTPClientTimeout)
if c.HTTPClientTimeout != 10*time.Second {
t.Errorf("Timeout incorrectly converted: 10 -> %d", c.HTTPClientTimeout)
}
}

0 comments on commit 2c914f0

Please sign in to comment.