config: dir on Config should be an absolute path

This commit is contained in:
Mitchell Hashimoto 2014-09-14 19:55:38 -07:00
parent f8836290da
commit e96fe43814
2 changed files with 12 additions and 2 deletions

View File

@ -104,6 +104,12 @@ func LoadDir(root string) (*Config, error) {
root)
}
// Determine the absolute path to the directory.
rootAbs, err := filepath.Abs(root)
if err != nil {
return nil, err
}
var result *Config
// Sort the files and overrides so we have a deterministic order
@ -141,7 +147,7 @@ func LoadDir(root string) (*Config, error) {
}
// Mark the directory
result.Dir = root
result.Dir = rootAbs
return result, nil
}

View File

@ -164,7 +164,11 @@ func TestLoadDir_basic(t *testing.T) {
t.Fatal("config should not be nil")
}
if c.Dir != dir {
dirAbs, err := filepath.Abs(dir)
if err != nil {
t.Fatalf("err: %s", err)
}
if c.Dir != dirAbs {
t.Fatalf("bad: %#v", c.Dir)
}