mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-11 18:11:21 +08:00
refactor & fix: stub driver and server
This commit is contained in:
@@ -14,12 +14,17 @@ import (
|
||||
"github.com/httprunner/httprunner/v5/pkg/uixt/option"
|
||||
)
|
||||
|
||||
func (p RouterBaseMethod) GetDriver(c *gin.Context) (driverExt uixt.IXTDriver, err error) {
|
||||
func (r *Router) GetDriver(c *gin.Context) (driverExt *uixt.XTDriver, err error) {
|
||||
driverObj, exists := c.Get("driver")
|
||||
if exists {
|
||||
return driverObj.(*uixt.XTDriver), nil
|
||||
}
|
||||
|
||||
deviceObj, exists := c.Get("device")
|
||||
var device uixt.IDevice
|
||||
var driver uixt.IDriver
|
||||
if !exists {
|
||||
device, err = p.GetDevice(c)
|
||||
device, err = r.GetDevice(c)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -32,14 +37,14 @@ func (p RouterBaseMethod) GetDriver(c *gin.Context) (driverExt uixt.IXTDriver, e
|
||||
RenderErrorInitDriver(c, err)
|
||||
return
|
||||
}
|
||||
c.Set("driver", driver)
|
||||
|
||||
driverExt = uixt.NewXTDriver(driver,
|
||||
ai.WithCVService(ai.CVServiceTypeVEDEM))
|
||||
c.Set("driver", driverExt)
|
||||
return driverExt, nil
|
||||
}
|
||||
|
||||
func (p RouterBaseMethod) GetDevice(c *gin.Context) (device uixt.IDevice, err error) {
|
||||
func (r *Router) GetDevice(c *gin.Context) (device uixt.IDevice, err error) {
|
||||
platform := c.Param("platform")
|
||||
serial := c.Param("serial")
|
||||
if serial == "" {
|
||||
|
||||
Reference in New Issue
Block a user