helper/schema: more tests

This commit is contained in:
Mitchell Hashimoto 2014-08-17 20:48:50 -07:00
parent d321240042
commit 539e4da03f
1 changed files with 34 additions and 0 deletions

View File

@ -796,3 +796,37 @@ func TestResourceDataState(t *testing.T) {
}
}
}
func TestResourceDataSetId(t *testing.T) {
d := &ResourceData{}
d.SetId("foo")
actual := d.State()
if actual.ID != "foo" {
t.Fatalf("bad: %#v", actual)
}
}
func TestResourceDataSetId_clear(t *testing.T) {
d := &ResourceData{
state: &terraform.ResourceState{ID: "bar"},
}
d.SetId("")
actual := d.State()
if actual.ID != "" {
t.Fatalf("bad: %#v", actual)
}
}
func TestResourceDataSetId_override(t *testing.T) {
d := &ResourceData{
state: &terraform.ResourceState{ID: "bar"},
}
d.SetId("foo")
actual := d.State()
if actual.ID != "foo" {
t.Fatalf("bad: %#v", actual)
}
}