terraform: tests for the plan graph builder
This commit is contained in:
parent
7557e6e70a
commit
dbac0785bc
|
@ -0,0 +1,52 @@
|
|||
package terraform
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPlanGraphBuilder_impl(t *testing.T) {
|
||||
var _ GraphBuilder = new(PlanGraphBuilder)
|
||||
}
|
||||
|
||||
func TestPlanGraphBuilder(t *testing.T) {
|
||||
b := &PlanGraphBuilder{
|
||||
Module: testModule(t, "graph-builder-plan-basic"),
|
||||
Providers: []string{"aws", "openstack"},
|
||||
DisableReduce: true,
|
||||
}
|
||||
|
||||
g, err := b.Build(RootModulePath)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(g.Path, RootModulePath) {
|
||||
t.Fatalf("bad: %#v", g.Path)
|
||||
}
|
||||
|
||||
actual := strings.TrimSpace(g.String())
|
||||
expected := strings.TrimSpace(testPlanGraphBuilderStr)
|
||||
if actual != expected {
|
||||
t.Fatalf("bad: %s", actual)
|
||||
}
|
||||
}
|
||||
|
||||
const testPlanGraphBuilderStr = `
|
||||
aws_instance.web
|
||||
aws_security_group.firewall
|
||||
provider.aws
|
||||
var.foo
|
||||
aws_load_balancer.weblb
|
||||
aws_instance.web
|
||||
provider.aws
|
||||
aws_security_group.firewall
|
||||
provider.aws
|
||||
openstack_floating_ip.random
|
||||
provider.openstack
|
||||
provider.aws
|
||||
openstack_floating_ip.random
|
||||
provider.openstack
|
||||
var.foo
|
||||
`
|
|
@ -0,0 +1,24 @@
|
|||
variable "foo" {
|
||||
default = "bar"
|
||||
description = "bar"
|
||||
}
|
||||
|
||||
provider "aws" {
|
||||
foo = "${openstack_floating_ip.random.value}"
|
||||
}
|
||||
|
||||
resource "openstack_floating_ip" "random" {}
|
||||
|
||||
resource "aws_security_group" "firewall" {}
|
||||
|
||||
resource "aws_instance" "web" {
|
||||
ami = "${var.foo}"
|
||||
security_groups = [
|
||||
"foo",
|
||||
"${aws_security_group.firewall.foo}"
|
||||
]
|
||||
}
|
||||
|
||||
resource "aws_load_balancer" "weblb" {
|
||||
members = "${aws_instance.web.id_list}"
|
||||
}
|
Loading…
Reference in New Issue