File tree 3 files changed +20
-2
lines changed
3 files changed +20
-2
lines changed Original file line number Diff line number Diff line change 42
42
desc : Run tests
43
43
cmds :
44
44
- echo "Running tests..."
45
- - go test ./... -v
45
+ - go test ./...
46
46
47
47
run :
48
48
desc : Run the application locally
Original file line number Diff line number Diff line change @@ -30,6 +30,11 @@ func init() {
30
30
return "" , fmt .Errorf ("device not found" )
31
31
}
32
32
}
33
+
34
+ // Mock USB host support check
35
+ device .CheckUSBHostSupport = func () (bool , bool , error ) {
36
+ return true , true , nil
37
+ }
33
38
}
34
39
35
40
func TestParseFlags (t * testing.T ) {
@@ -110,11 +115,13 @@ func TestMain(t *testing.T) {
110
115
// Save original values
111
116
originalExit := osExit
112
117
originalFindInputDevice := device .FindInputDeviceFunc
118
+ originalCheckUSBHostSupport := device .CheckUSBHostSupport
113
119
114
120
// Restore after test
115
121
defer func () {
116
122
osExit = originalExit
117
123
device .FindInputDeviceFunc = originalFindInputDevice
124
+ device .CheckUSBHostSupport = originalCheckUSBHostSupport
118
125
log .SetOutput (os .Stderr )
119
126
}()
120
127
@@ -130,6 +137,11 @@ func TestMain(t *testing.T) {
130
137
}
131
138
}
132
139
140
+ // Mock USB host support check
141
+ device .CheckUSBHostSupport = func () (bool , bool , error ) {
142
+ return true , true , nil
143
+ }
144
+
133
145
// Mock os.Exit
134
146
osExit = func (code int ) {
135
147
exitCalled = true
Original file line number Diff line number Diff line change @@ -5,8 +5,14 @@ import (
5
5
"strings"
6
6
)
7
7
8
+ // CheckUSBHostSupportFunc is a type for the host support check function
9
+ type CheckUSBHostSupportFunc func () (bool , bool , error )
10
+
11
+ // CheckUSBHostSupport is the function variable that can be replaced in tests
12
+ var CheckUSBHostSupport CheckUSBHostSupportFunc = checkUSBHostSupport
13
+
8
14
// CheckUSBHostSupport verifies both USB host hardware capability and if it's enabled
9
- func CheckUSBHostSupport () (hasCapability bool , isEnabled bool , err error ) {
15
+ func checkUSBHostSupport () (hasCapability bool , isEnabled bool , err error ) {
10
16
// Check hardware capability first
11
17
hasCapability = false
12
18
You can’t perform that action at this time.
0 commit comments