Skip to content

Commit

Permalink
Add tests for config.go
Browse files Browse the repository at this point in the history
  • Loading branch information
kelseyhightower committed Oct 18, 2013
1 parent 37ea79c commit d4807c9
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions config_test.go
Original file line number Diff line number Diff line change
@@ -1 +1,54 @@
package main

import (
"testing"
)

func TestInitConfig(t *testing.T) {
var expected = struct {
clientCert string
clientKey string
configDir string
etcdNodes []string
interval int
onetime bool
prefix string
templateDir string
}{
"", "", "/etc/confd/conf.d", []string{"http://127.0.0.1:4001"},
600, false, "/", "/etc/confd/templates",
}
InitConfig()
cc := ClientCert()
if cc != expected.clientCert {
t.Errorf("Expected default clientCert = %s, got %s", expected.clientCert, cc)
}
ck := ClientKey()
if ck != expected.clientKey {
t.Errorf("Expected default clientKey = %s, got %s", expected.clientKey, ck)
}
cd := ConfigDir()
if cd != expected.configDir {
t.Errorf("Expected default configDir = %s, got %s", expected.configDir, cd)
}
en := EtcdNodes()
if en[0] != expected.etcdNodes[0] {
t.Errorf("Expected default etcdNodes = %v, got %v", expected.etcdNodes, en)
}
i := Interval()
if i != expected.interval {
t.Errorf("Expected default interval = %d, got %d", expected.interval, i)
}
ot := Onetime()
if ot != expected.onetime {
t.Errorf("Expected default onetime = %v, got %v", expected.onetime, ot)
}
p := Prefix()
if p != expected.prefix {
t.Errorf("Expected default prefix = %s, got %s", expected.prefix, p)
}
td := TemplateDir()
if td != expected.templateDir {
t.Errorf("Expected default templateDir = %s, got %s", expected.templateDir, td)
}
}

0 comments on commit d4807c9

Please sign in to comment.