Move usb_test to a separate package, in line with opensource Go

expectations. Multiple packages per directory are not supported in this
realm ;) And with a separate package, the dot import seems unnecessary.
This commit is contained in:
Sebastian Zagrodzki
2017-02-05 16:29:22 +01:00
parent f13728c6e1
commit 4d60ebb065

View File

@@ -20,22 +20,22 @@ import (
"os" "os"
"testing" "testing"
. "github.com/kylelemons/gousb/usb" "github.com/kylelemons/gousb/usb"
"github.com/kylelemons/gousb/usbid" "github.com/kylelemons/gousb/usbid"
) )
func TestNoop(t *testing.T) { func TestNoop(t *testing.T) {
c := NewContext() c := usb.NewContext()
defer c.Close() defer c.Close()
c.Debug(0) c.Debug(0)
} }
func TestEnum(t *testing.T) { func TestEnum(t *testing.T) {
c := NewContext() c := usb.NewContext()
defer c.Close() defer c.Close()
c.Debug(0) c.Debug(0)
logDevice := func(t *testing.T, desc *Descriptor) { logDevice := func(t *testing.T, desc *usb.Descriptor) {
t.Logf("%03d.%03d %s", desc.Bus, desc.Address, usbid.Describe(desc)) t.Logf("%03d.%03d %s", desc.Bus, desc.Address, usbid.Describe(desc))
t.Logf("- Protocol: %s", usbid.Classify(desc)) t.Logf("- Protocol: %s", usbid.Classify(desc))
@@ -55,8 +55,8 @@ func TestEnum(t *testing.T) {
} }
} }
descs := []*Descriptor{} descs := []*usb.Descriptor{}
devs, err := c.ListDevices(func(desc *Descriptor) bool { devs, err := c.ListDevices(func(desc *usb.Descriptor) bool {
logDevice(t, desc) logDevice(t, desc)
descs = append(descs, desc) descs = append(descs, desc)
return true return true
@@ -82,12 +82,12 @@ func TestEnum(t *testing.T) {
} }
func TestOpenDeviceWithVidPid(t *testing.T) { func TestOpenDeviceWithVidPid(t *testing.T) {
c := NewContext() c := usb.NewContext()
defer c.Close() defer c.Close()
c.Debug(0) c.Debug(0)
// Accept for all device // Accept for all device
devs, err := c.ListDevices(func(desc *Descriptor) bool { devs, err := c.ListDevices(func(desc *usb.Descriptor) bool {
return true return true
}) })
defer func() { defer func() {
@@ -125,8 +125,8 @@ func TestMultipleContexts(t *testing.T) {
var buf bytes.Buffer var buf bytes.Buffer
log.SetOutput(&buf) log.SetOutput(&buf)
for i := 0; i < 2; i++ { for i := 0; i < 2; i++ {
ctx := NewContext() ctx := usb.NewContext()
_, err := ctx.ListDevices(func(desc *Descriptor) bool { _, err := ctx.ListDevices(func(desc *usb.Descriptor) bool {
return false return false
}) })
if err != nil { if err != nil {