d3c5196474
This diff changes the software name used by unattended runs for which we did not override the default software name (`ooniprobe-cli`). It will become `ooniprobe-cli-unattended`. This software name is in line with the one we use for Android, iOS, and desktop unattended runs. While working in this diff, I introduced string constants for the run types and a string constant for the default software name. See https://github.com/ooni/probe/issues/2081.
38 lines
873 B
Go
38 lines
873 B
Go
package ooapi_test
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"log"
|
|
|
|
"github.com/ooni/probe-cli/v3/internal/kvstore"
|
|
"github.com/ooni/probe-cli/v3/internal/model"
|
|
"github.com/ooni/probe-cli/v3/internal/ooapi"
|
|
"github.com/ooni/probe-cli/v3/internal/ooapi/apimodel"
|
|
)
|
|
|
|
func ExampleClient() {
|
|
clnt := &ooapi.Client{
|
|
KVStore: &kvstore.Memory{},
|
|
}
|
|
ctx := context.Background()
|
|
resp, err := clnt.CheckIn(ctx, &apimodel.CheckInRequest{
|
|
Charging: false,
|
|
OnWiFi: false,
|
|
Platform: "linux",
|
|
ProbeASN: "AS30722",
|
|
ProbeCC: "IT",
|
|
RunType: model.RunTypeTimed,
|
|
SoftwareName: "miniooni",
|
|
SoftwareVersion: "0.1.0-dev",
|
|
WebConnectivity: apimodel.CheckInRequestWebConnectivity{
|
|
CategoryCodes: []string{"NEWS"},
|
|
},
|
|
})
|
|
fmt.Printf("%+v\n", err)
|
|
// Output: <nil>
|
|
if resp == nil {
|
|
log.Fatal("expected non-nil response")
|
|
}
|
|
}
|