Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yaptest example #30

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
yaptest example
xushiwei committed Jan 22, 2024
commit 3041afb67b440490ad1d89de8c2ab16fb76569e5
16 changes: 13 additions & 3 deletions ytest/classfile.go
Original file line number Diff line number Diff line change
@@ -17,12 +17,15 @@
package ytest

import (
"fmt"
"io"
"net/http"
"strings"
)

const (
GopPackage = true
)

// -----------------------------------------------------------------------------

type App struct {
@@ -48,6 +51,13 @@ func Gopt_App_Main(app interface{ initApp() *App }, workers ...interface{ initCa
}
}

// Host replaces a host into real. For example:
//
// host "https://example.com" "http://localhost:8080"
// host "http://example.com" "http://localhost:8888"
func (p *App) Host(host, real string) {
}

func (p *App) hostOf(url string) (host string, url2 string, ok bool) {
// http://host/xxx or https://host/xxx
var istart int
@@ -84,8 +94,8 @@ func (p *App) newRequest(method, url string, body io.Reader) (req *http.Request,

// -----------------------------------------------------------------------------

func Echo(v ...any) {
fmt.Println(v...)
func Oauth2(auth string) RTComposer {
return nil
}

// -----------------------------------------------------------------------------
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions ytest/request.go
Original file line number Diff line number Diff line change
@@ -278,3 +278,5 @@ func (p *Request) RetWith(code any) *Request {
func (p *Request) Resp() *Response {
return p.resp
}

// -----------------------------------------------------------------------------
4 changes: 4 additions & 0 deletions ytest/response.go
Original file line number Diff line number Diff line change
@@ -67,6 +67,10 @@ func (p *Response) MatchHeader(key string, value any) {
}
}

func (p *Response) Body() any {
return nil
}

func (p *Response) MatchBody(bodyType string, body any) {
}