package ignition import ( "fmt" "testing" "github.com/coreos/ignition/config/types" ) func TestIngnitionGroup(t *testing.T) { testIgnition(t, ` resource "ignition_group" "foo" { name = "foo" password_hash = "password" gid = 42 } resource "ignition_group" "qux" { name = "qux" } resource "ignition_config" "test" { groups = [ "${ignition_group.foo.id}", "${ignition_group.qux.id}", ] } `, func(c *types.Config) error { if len(c.Passwd.Groups) != 2 { return fmt.Errorf("groups, found %d", len(c.Passwd.Groups)) } g := c.Passwd.Groups[0] if g.Name != "foo" { return fmt.Errorf("name, found %q", g.Name) } if g.PasswordHash != "password" { return fmt.Errorf("password_hash, found %q", g.PasswordHash) } if g.Gid == nil || *g.Gid != uint(42) { return fmt.Errorf("gid, found %q", *g.Gid) } g = c.Passwd.Groups[1] if g.Name != "qux" { return fmt.Errorf("name, found %q", g.Name) } if g.Gid != nil { return fmt.Errorf("uid, found %d", *g.Gid) } return nil }) }