From fceea12adea988f018b6fbab276797e446ca42a1 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 30 Jun 2014 21:25:15 -0700 Subject: [PATCH] terraform: some basic validation --- terraform/graph.go | 4 ++++ terraform/graph_test.go | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/terraform/graph.go b/terraform/graph.go index a464b0c6f6..002b7ae9ce 100644 --- a/terraform/graph.go +++ b/terraform/graph.go @@ -77,6 +77,10 @@ type GraphNodeResourceProvider struct { // configured at this point. // func Graph(opts *GraphOpts) (*depgraph.Graph, error) { + if opts.Config == nil { + return nil, errors.New("Config is required for Graph") + } + g := new(depgraph.Graph) // First, build the initial resource graph. This only has the resources diff --git a/terraform/graph_test.go b/terraform/graph_test.go index 04821ed668..cb38bcd65b 100644 --- a/terraform/graph_test.go +++ b/terraform/graph_test.go @@ -21,6 +21,12 @@ func TestGraph(t *testing.T) { } } +func TestGraph_configRequired(t *testing.T) { + if _, err := Graph(new(GraphOpts)); err == nil { + t.Fatal("should error") + } +} + func TestGraph_cycle(t *testing.T) { config := testConfig(t, "graph-cycle")