github.com/recobe182/terraform@v0.8.5-0.20170117231232-49ab22a935b7/builtin/providers/ignition/resource_ignition_networkd_unit_test.go (about)

     1  package ignition
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  
     7  	"github.com/coreos/ignition/config/types"
     8  )
     9  
    10  func TestIngnitionNetworkdUnit(t *testing.T) {
    11  	testIgnition(t, `
    12  		resource "ignition_networkd_unit" "foo" {
    13  			name = "foo.link"
    14  			content = "[Match]\nName=eth0\n\n[Network]\nAddress=10.0.1.7\n"
    15  		}
    16  
    17  		resource "ignition_config" "test" {
    18  			networkd = [
    19  				"${ignition_networkd_unit.foo.id}",
    20  			]
    21  		}
    22  	`, func(c *types.Config) error {
    23  		if len(c.Networkd.Units) != 1 {
    24  			return fmt.Errorf("networkd, found %d", len(c.Networkd.Units))
    25  		}
    26  
    27  		u := c.Networkd.Units[0]
    28  
    29  		if u.Name != "foo.link" {
    30  			return fmt.Errorf("name, found %q", u.Name)
    31  		}
    32  
    33  		if u.Contents != "[Match]\nName=eth0\n\n[Network]\nAddress=10.0.1.7\n" {
    34  			return fmt.Errorf("content, found %q", u.Contents)
    35  		}
    36  
    37  		return nil
    38  	})
    39  }