mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-18 08:06:59 +00:00
test: fix most integration tests (live)
This commit is contained in:
@ -29,20 +29,20 @@ type fakeCall struct {
|
||||
request []byte
|
||||
}
|
||||
|
||||
func (cntrl *Controller) recordCall(method, path string, request []byte) {
|
||||
cntrl.lock.Lock()
|
||||
defer cntrl.lock.Unlock()
|
||||
func (ctl *Controller) recordCall(method, path string, request []byte) {
|
||||
ctl.lock.Lock()
|
||||
defer ctl.lock.Unlock()
|
||||
|
||||
cntrl.calls = append(cntrl.calls, &fakeCall{
|
||||
ctl.calls = append(ctl.calls, &fakeCall{
|
||||
method: method,
|
||||
path: path,
|
||||
request: request,
|
||||
})
|
||||
}
|
||||
|
||||
func (cntrl *Controller) PrintCalls() {
|
||||
func (ctl *Controller) PrintCalls() {
|
||||
fmt.Println("API calls:")
|
||||
for idx, call := range cntrl.calls {
|
||||
for idx, call := range ctl.calls {
|
||||
fmt.Printf("%02d: [%s] %s\n", idx+1, call.method, call.path)
|
||||
if call.request != nil && string(call.request) != "null" {
|
||||
fmt.Printf("\t%s\n", call.request)
|
||||
@ -50,8 +50,8 @@ func (cntrl *Controller) PrintCalls() {
|
||||
}
|
||||
}
|
||||
|
||||
func (cntrl *Controller) WasCalled(method, path string, expectedRequest []byte) bool {
|
||||
for _, call := range cntrl.calls {
|
||||
func (ctl *Controller) WasCalled(method, path string, expectedRequest []byte) bool {
|
||||
for _, call := range ctl.calls {
|
||||
if call.method != method && call.path != path {
|
||||
continue
|
||||
}
|
||||
@ -64,9 +64,9 @@ func (cntrl *Controller) WasCalled(method, path string, expectedRequest []byte)
|
||||
return false
|
||||
}
|
||||
|
||||
func (cntrl *Controller) GetCalls(method, path string) [][]byte {
|
||||
func (ctl *Controller) GetCalls(method, path string) [][]byte {
|
||||
requests := [][]byte{}
|
||||
for _, call := range cntrl.calls {
|
||||
for _, call := range ctl.calls {
|
||||
if call.method == method && call.path == path {
|
||||
requests = append(requests, call.request)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user