config/module: proper name for root

This commit is contained in:
Mitchell Hashimoto 2014-09-22 16:39:01 -07:00
parent 46c1209c92
commit 97da02c368
2 changed files with 6 additions and 3 deletions

View File

@ -10,6 +10,9 @@ import (
"github.com/hashicorp/terraform/config" "github.com/hashicorp/terraform/config"
) )
// RootName is the name of the root tree.
const RootName = "root"
// Tree represents the module import tree of configurations. // Tree represents the module import tree of configurations.
// //
// This Tree structure can be used to get (download) new modules, load // This Tree structure can be used to get (download) new modules, load
@ -100,7 +103,7 @@ func (t *Tree) Modules() []*Module {
// tree and then the module name given for any children. // tree and then the module name given for any children.
func (t *Tree) Name() string { func (t *Tree) Name() string {
if t.name == "" { if t.name == "" {
return "<root>" return RootName
} }
return t.name return t.name

View File

@ -75,7 +75,7 @@ func TestTreeName(t *testing.T) {
tree := NewTree("", testConfig(t, "basic")) tree := NewTree("", testConfig(t, "basic"))
actual := tree.Name() actual := tree.Name()
if actual != "<root>" { if actual != RootName {
t.Fatalf("bad: %#v", actual) t.Fatalf("bad: %#v", actual)
} }
} }
@ -150,6 +150,6 @@ func TestTreeValidate_notLoaded(t *testing.T) {
const treeLoadStr = ` const treeLoadStr = `
<root> root
foo foo
` `