// Tests that Resources outside of the main 'resource' package work
// correctly and that non-pointer Resources work
Tests that Resources outside of the main 'resource' package work
correctly and that non-pointer Resources work
// Tests that Resources outside of the main ' resource ' package work // correctly and that non - pointer Resources work
func TestPlanToDOT(t *testing.T) {
	b := NewBuilder()
	b.AddResource("foo", &testResource{ID: "foo"})
	b.AddResource("bar", &testResource{ID: "bar"}, DependOn("foo"))
	b.AddResource("baz", &testResource{ID: "baz"}, DependOn("bar"))
	b.AddResource("quux", &testResource{ID: "quux"}, DependOn("baz"))
	b.AddResource("erf", nonPointerResource{"erf"}, DependOn("foo", "bar"))
	b.AddResource("alone", nonPointerResource{"alone"})
	testcases := []struct {
		exp string
		msg string
	}{
		{"\t\"alone\"", "Didn't find resource w/o deps"},
		{"\t\"foo\"", "should be w/o deps"},
		{"\t\"baz\" -> \"quux\" [style=bold color=blue]\n", "quux should depend on bar"},
		{"\t\"bar\" -> \"erf\" [style=bold color=blue]\n", "erf should depend on bar"},
		{"\t\"foo\" -> \"erf\" [style=bold color=blue]\n", "erf should depend on foo"},
	}
	p, err := b.Plan()
	assert.NoError(t, err)
	s := p.ToDOT()
	for _, tc := range testcases {
		assert.True(t, strings.Index(s, tc.exp) > 0, tc.msg)
	}
}
func TestPlanToDOT ( t * testing . T ) { b := NewBuilder ( ) b . AddResource ( " " , & testResource { ID : " " } ) b . AddResource ( " " , & testResource { ID : " " } , DependOn ( " " ) ) b . AddResource ( " " , & testResource { ID : " " } , DependOn ( " " ) ) b . AddResource ( " " , & testResource { ID : " " } , DependOn ( " " ) ) b . AddResource ( " " , nonPointerResource { " " } , DependOn ( " " , " " ) ) b . AddResource ( " " , nonPointerResource { " " } ) testcases := [ ] struct { exp string msg string } { { " \t \" \" " , " " } , { " \t \" \" " , " " } , { " \t \" \" \" \" \n " , " " } , { " \t \" \" \" \" \n " , " " } , { " \t \" \" \" \" \n " , " " } , } p , err := b . Plan ( ) assert . NoError ( t , err ) s := p . ToDOT ( ) for _ , tc := range testcases { assert . True ( t , strings . Index ( s , tc . exp ) > 0 , tc . msg ) } }
Tests that Resources outside of the main 'resource' package work
correctly and that non-pointer Resources work
Tests that Resources outside of the main ' resource ' package work correctly and that non - pointer Resources work