2023-08-27 09:31:03 +00:00
|
|
|
package devicepath_test
|
|
|
|
|
2023-08-27 13:09:30 +00:00
|
|
|
import (
|
|
|
|
"testing"
|
2023-08-27 09:31:03 +00:00
|
|
|
|
2023-09-16 14:20:09 +00:00
|
|
|
"git.faercol.me/faercol/devicepath"
|
2023-08-27 13:09:30 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
2023-08-27 09:31:03 +00:00
|
|
|
|
2023-08-27 13:09:30 +00:00
|
|
|
func TestOK(t *testing.T) {
|
|
|
|
input := "Sata(1,65535,0)"
|
|
|
|
res, err := devicepath.Parsenode(input)
|
|
|
|
require.NoError(t, err)
|
|
|
|
assert.Equal(t, devicepath.MessagingDevicePath, res.Type())
|
|
|
|
assert.Equal(t, devicepath.SATAMessaging, res.SubType())
|
|
|
|
assert.Equal(t, "Sata(1,65535,0)", res.String())
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestParseDevicePathOK(t *testing.T) {
|
|
|
|
input := "PciRoot(0x0)/Pci(0x1,0x2)/Pci(0x0,0x1)/Sata(0,65535,0)"
|
|
|
|
res, err := devicepath.ParseDevicePath(input)
|
|
|
|
require.NoError(t, err)
|
|
|
|
assert.Equal(t, "PciRoot(0x0)/Pci(0x1,0x2)/Pci(0x0,0x1)/Sata(0,65535,0)", res.String())
|
2023-08-27 09:31:03 +00:00
|
|
|
}
|