ooni-probe-cli/internal/engine/ooapi/fakeapi_test.go
Simone Basso 55bdebe8b2
engine/ooapi: autogenerated API with login and caching (#234)
* internal/engine/ooapi: auto-generated API client

* feat: introduce the callers abstraction

* feat: implement API caching on disk

* feat: implement cloneWithToken when we require login

* feat: implement login

* fix: do not cache all APIs

* feat: start making space for more tests

* feat: implement caching policy

* feat: write tests for caching layer

* feat: add integration tests and fix some minor issues

* feat: write much more unit tests

* feat: add some more easy unit tests

* feat: add tests that use a local server

While there, make sure many fields we care about are OK.

* doc: write basic documentation

* fix: tweak sentence

* doc: improve ooapi documentation

* doc(ooapi): other documentation improvements

* fix(ooapi): remove caching for most APIs

We discussed this topic yesterday with @FedericoCeratto. The only
place where we want LRU caching is MeasurementMeta.

* feat(ooapi): improve handling of errors during login

This was also discussed yesterday with @FedericoCeratto

* fix(swaggerdiff_test.go): temporarily disable

Before I work on this, I need to tend onto other tasks.

* fix(ootest): add one more test case

We're going towards 100% coverage of this package, as it ought to be.

* feat(ooapi): test cases for when the probe clock is off

* fix(ooapi): change test to have 100% unittest coverage

* feat: sync server and client APIs definition

Companion PR: https://github.com/ooni/api/pull/218

* fix(ooapi): start testing again against API

* fix(ooapi): only generate each file once

* chore: set version to 3.7.0-alpha

While there, make sure we don't always skip a currently failing
riseupvpn test, and slightly clarify the readme.

* fix(kvstore): less scoped error message
2021-03-04 11:51:07 +01:00

191 lines
4.6 KiB
Go

// Code generated by go generate; DO NOT EDIT.
// 2021-02-26 15:45:52.357709034 +0100 CET m=+0.000208565
package ooapi
//go:generate go run ./internal/generator -file fakeapi_test.go
import (
"context"
"sync/atomic"
"github.com/ooni/probe-cli/v3/internal/engine/ooapi/apimodel"
)
type FakeCheckReportIDAPI struct {
Err error
Response *apimodel.CheckReportIDResponse
CountCall int32
}
func (fapi *FakeCheckReportIDAPI) Call(ctx context.Context, req *apimodel.CheckReportIDRequest) (*apimodel.CheckReportIDResponse, error) {
atomic.AddInt32(&fapi.CountCall, 1)
return fapi.Response, fapi.Err
}
var (
_ CheckReportIDCaller = &FakeCheckReportIDAPI{}
)
type FakeCheckInAPI struct {
Err error
Response *apimodel.CheckInResponse
CountCall int32
}
func (fapi *FakeCheckInAPI) Call(ctx context.Context, req *apimodel.CheckInRequest) (*apimodel.CheckInResponse, error) {
atomic.AddInt32(&fapi.CountCall, 1)
return fapi.Response, fapi.Err
}
var (
_ CheckInCaller = &FakeCheckInAPI{}
)
type FakeLoginAPI struct {
Err error
Response *apimodel.LoginResponse
CountCall int32
}
func (fapi *FakeLoginAPI) Call(ctx context.Context, req *apimodel.LoginRequest) (*apimodel.LoginResponse, error) {
atomic.AddInt32(&fapi.CountCall, 1)
return fapi.Response, fapi.Err
}
var (
_ LoginCaller = &FakeLoginAPI{}
)
type FakeMeasurementMetaAPI struct {
Err error
Response *apimodel.MeasurementMetaResponse
CountCall int32
}
func (fapi *FakeMeasurementMetaAPI) Call(ctx context.Context, req *apimodel.MeasurementMetaRequest) (*apimodel.MeasurementMetaResponse, error) {
atomic.AddInt32(&fapi.CountCall, 1)
return fapi.Response, fapi.Err
}
var (
_ MeasurementMetaCaller = &FakeMeasurementMetaAPI{}
)
type FakeRegisterAPI struct {
Err error
Response *apimodel.RegisterResponse
CountCall int32
}
func (fapi *FakeRegisterAPI) Call(ctx context.Context, req *apimodel.RegisterRequest) (*apimodel.RegisterResponse, error) {
atomic.AddInt32(&fapi.CountCall, 1)
return fapi.Response, fapi.Err
}
var (
_ RegisterCaller = &FakeRegisterAPI{}
)
type FakeTestHelpersAPI struct {
Err error
Response apimodel.TestHelpersResponse
CountCall int32
}
func (fapi *FakeTestHelpersAPI) Call(ctx context.Context, req *apimodel.TestHelpersRequest) (apimodel.TestHelpersResponse, error) {
atomic.AddInt32(&fapi.CountCall, 1)
return fapi.Response, fapi.Err
}
var (
_ TestHelpersCaller = &FakeTestHelpersAPI{}
)
type FakePsiphonConfigAPI struct {
WithResult PsiphonConfigCaller
Err error
Response apimodel.PsiphonConfigResponse
CountCall int32
}
func (fapi *FakePsiphonConfigAPI) Call(ctx context.Context, req *apimodel.PsiphonConfigRequest) (apimodel.PsiphonConfigResponse, error) {
atomic.AddInt32(&fapi.CountCall, 1)
return fapi.Response, fapi.Err
}
func (fapi *FakePsiphonConfigAPI) WithToken(token string) PsiphonConfigCaller {
return fapi.WithResult
}
var (
_ PsiphonConfigCaller = &FakePsiphonConfigAPI{}
_ PsiphonConfigCloner = &FakePsiphonConfigAPI{}
)
type FakeTorTargetsAPI struct {
WithResult TorTargetsCaller
Err error
Response apimodel.TorTargetsResponse
CountCall int32
}
func (fapi *FakeTorTargetsAPI) Call(ctx context.Context, req *apimodel.TorTargetsRequest) (apimodel.TorTargetsResponse, error) {
atomic.AddInt32(&fapi.CountCall, 1)
return fapi.Response, fapi.Err
}
func (fapi *FakeTorTargetsAPI) WithToken(token string) TorTargetsCaller {
return fapi.WithResult
}
var (
_ TorTargetsCaller = &FakeTorTargetsAPI{}
_ TorTargetsCloner = &FakeTorTargetsAPI{}
)
type FakeURLsAPI struct {
Err error
Response *apimodel.URLsResponse
CountCall int32
}
func (fapi *FakeURLsAPI) Call(ctx context.Context, req *apimodel.URLsRequest) (*apimodel.URLsResponse, error) {
atomic.AddInt32(&fapi.CountCall, 1)
return fapi.Response, fapi.Err
}
var (
_ URLsCaller = &FakeURLsAPI{}
)
type FakeOpenReportAPI struct {
Err error
Response *apimodel.OpenReportResponse
CountCall int32
}
func (fapi *FakeOpenReportAPI) Call(ctx context.Context, req *apimodel.OpenReportRequest) (*apimodel.OpenReportResponse, error) {
atomic.AddInt32(&fapi.CountCall, 1)
return fapi.Response, fapi.Err
}
var (
_ OpenReportCaller = &FakeOpenReportAPI{}
)
type FakeSubmitMeasurementAPI struct {
Err error
Response *apimodel.SubmitMeasurementResponse
CountCall int32
}
func (fapi *FakeSubmitMeasurementAPI) Call(ctx context.Context, req *apimodel.SubmitMeasurementRequest) (*apimodel.SubmitMeasurementResponse, error) {
atomic.AddInt32(&fapi.CountCall, 1)
return fapi.Response, fapi.Err
}
var (
_ SubmitMeasurementCaller = &FakeSubmitMeasurementAPI{}
)