2015-09-12 22:17:16 +00:00
|
|
|
package wire
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2024-06-11 16:25:58 +00:00
|
|
|
"github.com/timoxa0/goadb/internal/errors"
|
2020-07-13 06:18:10 +00:00
|
|
|
|
2015-09-12 22:17:16 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestAdbServerError_NoRequest(t *testing.T) {
|
|
|
|
err := adbServerError("", "fail")
|
2016-05-22 17:49:32 +00:00
|
|
|
assert.Equal(t, errors.Err{
|
|
|
|
Code: errors.AdbError,
|
2015-09-12 22:17:16 +00:00
|
|
|
Message: "server error: fail",
|
|
|
|
Details: ErrorResponseDetails{
|
|
|
|
Request: "",
|
|
|
|
ServerMsg: "fail",
|
|
|
|
},
|
2016-05-22 17:49:32 +00:00
|
|
|
}, *(err.(*errors.Err)))
|
2015-09-12 22:17:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestAdbServerError_WithRequest(t *testing.T) {
|
|
|
|
err := adbServerError("polite", "fail")
|
2016-05-22 17:49:32 +00:00
|
|
|
assert.Equal(t, errors.Err{
|
|
|
|
Code: errors.AdbError,
|
2015-09-12 22:17:16 +00:00
|
|
|
Message: "server error for polite request: fail",
|
|
|
|
Details: ErrorResponseDetails{
|
|
|
|
Request: "polite",
|
|
|
|
ServerMsg: "fail",
|
|
|
|
},
|
2016-05-22 17:49:32 +00:00
|
|
|
}, *(err.(*errors.Err)))
|
2015-09-12 22:17:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestAdbServerError_DeviceNotFound(t *testing.T) {
|
|
|
|
err := adbServerError("", "device not found")
|
2016-05-22 17:49:32 +00:00
|
|
|
assert.Equal(t, errors.Err{
|
|
|
|
Code: errors.DeviceNotFound,
|
2015-09-12 22:17:16 +00:00
|
|
|
Message: "server error: device not found",
|
|
|
|
Details: ErrorResponseDetails{
|
|
|
|
Request: "",
|
|
|
|
ServerMsg: "device not found",
|
|
|
|
},
|
2016-05-22 17:49:32 +00:00
|
|
|
}, *(err.(*errors.Err)))
|
2015-09-12 22:17:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestAdbServerError_DeviceSerialNotFound(t *testing.T) {
|
|
|
|
err := adbServerError("", "device 'LGV4801c74eccd' not found")
|
2016-05-22 17:49:32 +00:00
|
|
|
assert.Equal(t, errors.Err{
|
|
|
|
Code: errors.DeviceNotFound,
|
2015-09-12 22:17:16 +00:00
|
|
|
Message: "server error: device 'LGV4801c74eccd' not found",
|
|
|
|
Details: ErrorResponseDetails{
|
|
|
|
Request: "",
|
|
|
|
ServerMsg: "device 'LGV4801c74eccd' not found",
|
|
|
|
},
|
2016-05-22 17:49:32 +00:00
|
|
|
}, *(err.(*errors.Err)))
|
2015-09-12 22:17:16 +00:00
|
|
|
}
|