opentofu/builtin/providers/ignition/resource_ignition_disk_test.go
Máximo Cuadros 85f0fba9f9 Ignition provider (#6189)
* providers: ignition, basic config, version and config

* providers: ignition, user and passwd example, general cache implementation

* vendor: Capture new dependency upstream-pkg

* providers: ignition ignition_user

* providers: ignition ignition_disk, ignition_group and ignition_raid

* providers: ignition_file and ignition_filesystem

* providers: ignition_systemd_unit and ignition_networkd_unit

* providers: ignition_config improvements

* vendor: Capture new dependency upstream-pkg

* providers: ignition main

* documentation: ignition provider

* providers: ignition minor changes

* providers: ignition, fix test

* fixing tests and latest versions
2017-01-03 11:29:14 +00:00

61 lines
1.2 KiB
Go

package ignition
import (
"fmt"
"testing"
"github.com/coreos/ignition/config/types"
)
func TestIngnitionDisk(t *testing.T) {
testIgnition(t, `
resource "ignition_disk" "foo" {
device = "/foo"
partition {
label = "qux"
size = 42
start = 2048
type_guid = "01234567-89AB-CDEF-EDCB-A98765432101"
}
}
resource "ignition_config" "test" {
disks = [
"${ignition_disk.foo.id}",
]
}
`, func(c *types.Config) error {
if len(c.Storage.Disks) != 1 {
return fmt.Errorf("disks, found %d", len(c.Storage.Disks))
}
d := c.Storage.Disks[0]
if d.Device != "/foo" {
return fmt.Errorf("name, found %q", d.Device)
}
if len(d.Partitions) != 1 {
return fmt.Errorf("parition, found %d", len(d.Partitions))
}
p := d.Partitions[0]
if p.Label != "qux" {
return fmt.Errorf("parition.0.label, found %q", p.Label)
}
if p.Size != 42 {
return fmt.Errorf("parition.0.size, found %q", p.Size)
}
if p.Start != 2048 {
return fmt.Errorf("parition.0.start, found %q", p.Start)
}
if p.TypeGUID != "01234567-89AB-CDEF-EDCB-A98765432101" {
return fmt.Errorf("parition.0.type_guid, found %q", p.TypeGUID)
}
return nil
})
}