feat(ooapi): add toplevel client and simplify API (#248)
* feat(ooapi): add toplevel client and simplify API This diff should simplify using ooapi from other packages by adding more abstraction that wraps the existing code. Part of https://github.com/ooni/probe/issues/1355. * fix(ooapi): use correct comment for cloners See https://github.com/ooni/probe-cli/pull/248#discussion_r590663843 * fix(ooapi): make sure the documentation is current See https://github.com/ooni/probe-cli/pull/248#discussion_r590665773 * fix(ooapi): automate copying APIs See https://github.com/ooni/probe-cli/pull/248#discussion_r590665837 * feat(ooapi): add unit tests for clientcall.go See https://github.com/ooni/probe-cli/pull/248#discussion_r590666297 * fix(ooapi): rewrite integration tests to use toplevel API See https://github.com/ooni/probe-cli/pull/248#discussion_r590665084
This commit is contained in:
parent
c22828d369
commit
28ce79eff1
33 changed files with 2090 additions and 795 deletions
|
|
@ -1,5 +1,5 @@
|
|||
// Code generated by go generate; DO NOT EDIT.
|
||||
// 2021-02-26 15:45:52.357709034 +0100 CET m=+0.000208565
|
||||
// 2021-03-10 13:17:34.086220417 +0100 CET m=+0.000080714
|
||||
|
||||
package ooapi
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ func (fapi *FakeCheckReportIDAPI) Call(ctx context.Context, req *apimodel.CheckR
|
|||
}
|
||||
|
||||
var (
|
||||
_ CheckReportIDCaller = &FakeCheckReportIDAPI{}
|
||||
_ callerForCheckReportIDAPI = &FakeCheckReportIDAPI{}
|
||||
)
|
||||
|
||||
type FakeCheckInAPI struct {
|
||||
|
|
@ -39,7 +39,7 @@ func (fapi *FakeCheckInAPI) Call(ctx context.Context, req *apimodel.CheckInReque
|
|||
}
|
||||
|
||||
var (
|
||||
_ CheckInCaller = &FakeCheckInAPI{}
|
||||
_ callerForCheckInAPI = &FakeCheckInAPI{}
|
||||
)
|
||||
|
||||
type FakeLoginAPI struct {
|
||||
|
|
@ -54,7 +54,7 @@ func (fapi *FakeLoginAPI) Call(ctx context.Context, req *apimodel.LoginRequest)
|
|||
}
|
||||
|
||||
var (
|
||||
_ LoginCaller = &FakeLoginAPI{}
|
||||
_ callerForLoginAPI = &FakeLoginAPI{}
|
||||
)
|
||||
|
||||
type FakeMeasurementMetaAPI struct {
|
||||
|
|
@ -69,7 +69,7 @@ func (fapi *FakeMeasurementMetaAPI) Call(ctx context.Context, req *apimodel.Meas
|
|||
}
|
||||
|
||||
var (
|
||||
_ MeasurementMetaCaller = &FakeMeasurementMetaAPI{}
|
||||
_ callerForMeasurementMetaAPI = &FakeMeasurementMetaAPI{}
|
||||
)
|
||||
|
||||
type FakeRegisterAPI struct {
|
||||
|
|
@ -84,7 +84,7 @@ func (fapi *FakeRegisterAPI) Call(ctx context.Context, req *apimodel.RegisterReq
|
|||
}
|
||||
|
||||
var (
|
||||
_ RegisterCaller = &FakeRegisterAPI{}
|
||||
_ callerForRegisterAPI = &FakeRegisterAPI{}
|
||||
)
|
||||
|
||||
type FakeTestHelpersAPI struct {
|
||||
|
|
@ -99,11 +99,11 @@ func (fapi *FakeTestHelpersAPI) Call(ctx context.Context, req *apimodel.TestHelp
|
|||
}
|
||||
|
||||
var (
|
||||
_ TestHelpersCaller = &FakeTestHelpersAPI{}
|
||||
_ callerForTestHelpersAPI = &FakeTestHelpersAPI{}
|
||||
)
|
||||
|
||||
type FakePsiphonConfigAPI struct {
|
||||
WithResult PsiphonConfigCaller
|
||||
WithResult callerForPsiphonConfigAPI
|
||||
Err error
|
||||
Response apimodel.PsiphonConfigResponse
|
||||
CountCall int32
|
||||
|
|
@ -114,17 +114,17 @@ func (fapi *FakePsiphonConfigAPI) Call(ctx context.Context, req *apimodel.Psipho
|
|||
return fapi.Response, fapi.Err
|
||||
}
|
||||
|
||||
func (fapi *FakePsiphonConfigAPI) WithToken(token string) PsiphonConfigCaller {
|
||||
func (fapi *FakePsiphonConfigAPI) WithToken(token string) callerForPsiphonConfigAPI {
|
||||
return fapi.WithResult
|
||||
}
|
||||
|
||||
var (
|
||||
_ PsiphonConfigCaller = &FakePsiphonConfigAPI{}
|
||||
_ PsiphonConfigCloner = &FakePsiphonConfigAPI{}
|
||||
_ callerForPsiphonConfigAPI = &FakePsiphonConfigAPI{}
|
||||
_ clonerForPsiphonConfigAPI = &FakePsiphonConfigAPI{}
|
||||
)
|
||||
|
||||
type FakeTorTargetsAPI struct {
|
||||
WithResult TorTargetsCaller
|
||||
WithResult callerForTorTargetsAPI
|
||||
Err error
|
||||
Response apimodel.TorTargetsResponse
|
||||
CountCall int32
|
||||
|
|
@ -135,13 +135,13 @@ func (fapi *FakeTorTargetsAPI) Call(ctx context.Context, req *apimodel.TorTarget
|
|||
return fapi.Response, fapi.Err
|
||||
}
|
||||
|
||||
func (fapi *FakeTorTargetsAPI) WithToken(token string) TorTargetsCaller {
|
||||
func (fapi *FakeTorTargetsAPI) WithToken(token string) callerForTorTargetsAPI {
|
||||
return fapi.WithResult
|
||||
}
|
||||
|
||||
var (
|
||||
_ TorTargetsCaller = &FakeTorTargetsAPI{}
|
||||
_ TorTargetsCloner = &FakeTorTargetsAPI{}
|
||||
_ callerForTorTargetsAPI = &FakeTorTargetsAPI{}
|
||||
_ clonerForTorTargetsAPI = &FakeTorTargetsAPI{}
|
||||
)
|
||||
|
||||
type FakeURLsAPI struct {
|
||||
|
|
@ -156,7 +156,7 @@ func (fapi *FakeURLsAPI) Call(ctx context.Context, req *apimodel.URLsRequest) (*
|
|||
}
|
||||
|
||||
var (
|
||||
_ URLsCaller = &FakeURLsAPI{}
|
||||
_ callerForURLsAPI = &FakeURLsAPI{}
|
||||
)
|
||||
|
||||
type FakeOpenReportAPI struct {
|
||||
|
|
@ -171,7 +171,7 @@ func (fapi *FakeOpenReportAPI) Call(ctx context.Context, req *apimodel.OpenRepor
|
|||
}
|
||||
|
||||
var (
|
||||
_ OpenReportCaller = &FakeOpenReportAPI{}
|
||||
_ callerForOpenReportAPI = &FakeOpenReportAPI{}
|
||||
)
|
||||
|
||||
type FakeSubmitMeasurementAPI struct {
|
||||
|
|
@ -186,5 +186,5 @@ func (fapi *FakeSubmitMeasurementAPI) Call(ctx context.Context, req *apimodel.Su
|
|||
}
|
||||
|
||||
var (
|
||||
_ SubmitMeasurementCaller = &FakeSubmitMeasurementAPI{}
|
||||
_ callerForSubmitMeasurementAPI = &FakeSubmitMeasurementAPI{}
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue