devicepath/parser_test.go
Melora Hugues 54794b57a4
All checks were successful
continuous-integration/drone/push Build is passing
add beginning of parser
2023-08-27 15:09:30 +02:00

25 lines
742 B
Go

package devicepath_test
import (
"testing"
devicepath "git.faercol.me/faercol/device-path"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
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())
}