From ae2e2d77589bbf2e2cbecaf24de0e32a4d110ce1 Mon Sep 17 00:00:00 2001 From: Itxaka Date: Tue, 17 Sep 2024 13:10:26 +0200 Subject: [PATCH] Override the ghw paths on ghw mock (#496) --- ghw/mocks/ghw_mock.go | 4 ++++ go.sum | 1 + types/partitions.go | 8 ++++---- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ghw/mocks/ghw_mock.go b/ghw/mocks/ghw_mock.go index 2684755..ce2f560 100644 --- a/ghw/mocks/ghw_mock.go +++ b/ghw/mocks/ghw_mock.go @@ -48,6 +48,8 @@ func (g *GhwMock) CreateDevices() { d, _ := os.MkdirTemp("", "ghwmock") g.Chroot = d g.paths = ghw.NewPaths(d) + // Set the env override to the chroot + _ = os.Setenv("GHW_CHROOT", d) // Create the /sys/block dir _ = os.MkdirAll(g.paths.SysBlock, 0755) // Create the /run/udev/data dir @@ -157,5 +159,7 @@ func (g *GhwMock) RemovePartitionFromDisk(diskName string, partitionName string) // Clean will remove the chroot dir and unset the env var func (g *GhwMock) Clean() { + // Uset the test override + _ = os.Unsetenv("GHW_CHROOT") _ = os.RemoveAll(g.Chroot) } diff --git a/go.sum b/go.sum index 6e374ce..ddb58d9 100644 --- a/go.sum +++ b/go.sum @@ -359,6 +359,7 @@ github.com/saferwall/pe v1.5.4 h1:tLmMggEMUfeqrpJ25zS/okUQmyFdD5xWKL2+z9njCqg= github.com/saferwall/pe v1.5.4/go.mod h1:mJx+PuptmNpoPFBNhWs/uDMFL/kTHVZIkg0d4OUJFbQ= github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 h1:lZUw3E0/J3roVtGQ+SCrUrg3ON6NgVqpn3+iol9aGu4= github.com/santhosh-tekuri/jsonschema/v5 v5.3.1/go.mod h1:uToXkOrWAZ6/Oc07xWQrPOhJotwFIyu2bBVN41fcDUY= +github.com/santhosh-tekuri/jsonschema/v6 v6.0.1/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU= github.com/secDre4mer/pkcs7 v0.0.0-20240322103146-665324a4461d h1:RQqyEogx5J6wPdoxqL132b100j8KjcVHO1c0KLRoIhc= github.com/secDre4mer/pkcs7 v0.0.0-20240322103146-665324a4461d/go.mod h1:PegD7EVqlN88z7TpCqH92hHP+GBpfomGCCnw1PFtNOA= github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= diff --git a/types/partitions.go b/types/partitions.go index c2edfd0..0493a9f 100644 --- a/types/partitions.go +++ b/types/partitions.go @@ -6,10 +6,10 @@ type Partition struct { Size uint `yaml:"size,omitempty" mapstructure:"size"` FS string `yaml:"fs,omitempty" mapstrcuture:"fs"` Flags []string `yaml:"flags,omitempty" mapstrcuture:"flags"` - UUID string - MountPoint string `yaml:"-"` - Path string `yaml:"-"` - Disk string `yaml:"-"` + UUID string `yaml:"uuid,omitempty" mapstructure:"uuid"` + MountPoint string `yaml:"-"` + Path string `yaml:"-"` + Disk string `yaml:"-"` } type PartitionList []*Partition