mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-22 00:29:37 +08:00
refactor: move converter from hrp internal to pkg
This commit is contained in:
@@ -8,8 +8,8 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/convert"
|
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/version"
|
"github.com/httprunner/httprunner/v4/hrp/internal/version"
|
||||||
|
"github.com/httprunner/httprunner/v4/hrp/pkg/convert"
|
||||||
)
|
)
|
||||||
|
|
||||||
var convertCmd = &cobra.Command{
|
var convertCmd = &cobra.Command{
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/httprunner/httprunner/v4/hrp"
|
"github.com/httprunner/httprunner/v4/hrp"
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/convert"
|
|
||||||
"github.com/httprunner/httprunner/v4/hrp/pkg/boomer"
|
"github.com/httprunner/httprunner/v4/hrp/pkg/boomer"
|
||||||
|
"github.com/httprunner/httprunner/v4/hrp/pkg/convert"
|
||||||
)
|
)
|
||||||
|
|
||||||
var runCurlCmd = &cobra.Command{
|
var runCurlCmd = &cobra.Command{
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 58 KiB |
38
hrp/pkg/httpstat/demo/main_test.go
Normal file
38
hrp/pkg/httpstat/demo/main_test.go
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
package demo
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/httprunner/httprunner/v4/hrp/pkg/httpstat"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestMain(t *testing.T) {
|
||||||
|
var httpStat httpstat.Stat
|
||||||
|
|
||||||
|
req, _ := http.NewRequest("GET", "https://httprunner.com", nil)
|
||||||
|
ctx := httpstat.WithHTTPStat(req, &httpStat)
|
||||||
|
|
||||||
|
client := &http.Client{
|
||||||
|
Timeout: time.Second * 10,
|
||||||
|
}
|
||||||
|
|
||||||
|
req = req.WithContext(ctx)
|
||||||
|
resp, err := client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if resp != nil {
|
||||||
|
defer resp.Body.Close()
|
||||||
|
}
|
||||||
|
|
||||||
|
// get stat
|
||||||
|
httpStat.Finish()
|
||||||
|
result := httpStat.Durations()
|
||||||
|
fmt.Println(result)
|
||||||
|
|
||||||
|
// print stat
|
||||||
|
httpStat.Print()
|
||||||
|
}
|
||||||
@@ -67,7 +67,7 @@ func InitWDAClient(device *IOSDevice) (*DriverExt, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// switch to iOS springboard before init WDA session
|
// switch to iOS springboard before init WDA session
|
||||||
// aviod getting stuck when some super app is activate such as douyin or wexin
|
// avoid getting stuck when some super app is activate such as douyin or wexin
|
||||||
log.Info().Msg("go back to home screen")
|
log.Info().Msg("go back to home screen")
|
||||||
if err = driver.Homescreen(); err != nil {
|
if err = driver.Homescreen(); err != nil {
|
||||||
return nil, errors.Wrap(err, "failed to go back to home screen")
|
return nil, errors.Wrap(err, "failed to go back to home screen")
|
||||||
|
|||||||
Reference in New Issue
Block a user