GODT-35: New pmapi client and manager using resty

This commit is contained in:
James Houlahan
2021-02-22 18:23:51 +01:00
committed by Jakub
parent 1d538e8540
commit 2284e9ede1
163 changed files with 3333 additions and 8124 deletions

View File

@ -21,6 +21,7 @@ import (
"encoding/json"
"fmt"
"github.com/ProtonMail/proton-bridge/pkg/pmapi"
"github.com/nsf/jsondiff"
)
@ -39,23 +40,31 @@ type fakeCall struct {
request []byte
}
func (ctl *Controller) recordCall(method method, path string, req interface{}) {
func (ctl *Controller) recordCall(method method, path string, req interface{}) error {
ctl.lock.Lock()
defer ctl.lock.Unlock()
request := []byte{}
var request []byte
if req != nil {
var err error
request, err = json.Marshal(req)
if err != nil {
panic(err)
if request, err = json.Marshal(req); err != nil {
return err
}
}
ctl.calls = append(ctl.calls, &fakeCall{
method: method,
path: path,
request: request,
})
if ctl.noInternetConnection {
return pmapi.ErrNoConnection
}
return nil
}
func (ctl *Controller) PrintCalls() {