oonimkall: mobile api for running WebConnectivity (#223)
* poc: mobile api for running WebConnectivity Yesterday we had a team meeting where we discussed the importance of stopping using MK wrappers for running experiments. Here's a PoC showing how we can do that for WebConnectivity. It seems to me we probably want to add more tests and merge this code such that we can experiment with it quite soon. There seems to be opportunities for auto-generating code, BTW. While working on this PoC, I've also took a chance to revamp the external documentation of pkg/oonimkall. * feat: start making the code more abstract * chore: write unit tests for new code * fix(oonimkall): improve naming * refactor: cosmetic changes * fix: explain
This commit is contained in:
parent
53e6b694cb
commit
0f61778e7a
6 changed files with 481 additions and 17 deletions
|
|
@ -18,7 +18,7 @@ import (
|
|||
"github.com/ooni/probe-cli/v3/pkg/oonimkall"
|
||||
)
|
||||
|
||||
func NewSessionWithAssetsDir(assetsDir string) (*oonimkall.Session, error) {
|
||||
func NewSessionForTestingWithAssetsDir(assetsDir string) (*oonimkall.Session, error) {
|
||||
return oonimkall.NewSession(&oonimkall.SessionConfig{
|
||||
AssetsDir: assetsDir,
|
||||
ProbeServicesURL: "https://ams-pg-test.ooni.org/",
|
||||
|
|
@ -29,8 +29,8 @@ func NewSessionWithAssetsDir(assetsDir string) (*oonimkall.Session, error) {
|
|||
})
|
||||
}
|
||||
|
||||
func NewSession() (*oonimkall.Session, error) {
|
||||
return NewSessionWithAssetsDir("../testdata/oonimkall/assets")
|
||||
func NewSessionForTesting() (*oonimkall.Session, error) {
|
||||
return NewSessionForTestingWithAssetsDir("../testdata/oonimkall/assets")
|
||||
}
|
||||
|
||||
func TestNewSessionWithInvalidStateDir(t *testing.T) {
|
||||
|
|
@ -72,7 +72,7 @@ func TestMaybeUpdateResourcesWithCancelledContext(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
defer os.RemoveAll(dir)
|
||||
sess, err := NewSessionWithAssetsDir(dir)
|
||||
sess, err := NewSessionForTestingWithAssetsDir(dir)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -104,7 +104,7 @@ func TestGeolocateWithCancelledContext(t *testing.T) {
|
|||
if testing.Short() {
|
||||
t.Skip("skip test in short mode")
|
||||
}
|
||||
sess, err := NewSession()
|
||||
sess, err := NewSessionForTesting()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -123,7 +123,7 @@ func TestGeolocateGood(t *testing.T) {
|
|||
if testing.Short() {
|
||||
t.Skip("skip test in short mode")
|
||||
}
|
||||
sess, err := NewSession()
|
||||
sess, err := NewSessionForTesting()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -163,7 +163,7 @@ func TestSubmitWithCancelledContext(t *testing.T) {
|
|||
if testing.Short() {
|
||||
t.Skip("skip test in short mode")
|
||||
}
|
||||
sess, err := NewSession()
|
||||
sess, err := NewSessionForTesting()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -182,7 +182,7 @@ func TestSubmitWithInvalidJSON(t *testing.T) {
|
|||
if testing.Short() {
|
||||
t.Skip("skip test in short mode")
|
||||
}
|
||||
sess, err := NewSession()
|
||||
sess, err := NewSessionForTesting()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -234,7 +234,7 @@ func TestSubmitMeasurementGood(t *testing.T) {
|
|||
if testing.Short() {
|
||||
t.Skip("skip test in short mode")
|
||||
}
|
||||
sess, err := NewSession()
|
||||
sess, err := NewSessionForTesting()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -248,7 +248,7 @@ func TestSubmitCancelContextAfterFirstSubmission(t *testing.T) {
|
|||
if testing.Short() {
|
||||
t.Skip("skip test in short mode")
|
||||
}
|
||||
sess, err := NewSession()
|
||||
sess, err := NewSessionForTesting()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -267,7 +267,7 @@ func TestSubmitCancelContextAfterFirstSubmission(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCheckInSuccess(t *testing.T) {
|
||||
sess, err := NewSession()
|
||||
sess, err := NewSessionForTesting()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -315,7 +315,7 @@ func TestCheckInSuccess(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCheckInLookupLocationFailure(t *testing.T) {
|
||||
sess, err := NewSession()
|
||||
sess, err := NewSessionForTesting()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -342,7 +342,7 @@ func TestCheckInLookupLocationFailure(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCheckInNewProbeServicesFailure(t *testing.T) {
|
||||
sess, err := NewSession()
|
||||
sess, err := NewSessionForTesting()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -371,7 +371,7 @@ func TestCheckInNewProbeServicesFailure(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCheckInCheckInFailure(t *testing.T) {
|
||||
sess, err := NewSession()
|
||||
sess, err := NewSessionForTesting()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -400,7 +400,7 @@ func TestCheckInCheckInFailure(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCheckInNoParams(t *testing.T) {
|
||||
sess, err := NewSession()
|
||||
sess, err := NewSessionForTesting()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -423,7 +423,7 @@ func TestCheckInNoParams(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestFetchURLListSuccess(t *testing.T) {
|
||||
sess, err := NewSession()
|
||||
sess, err := NewSessionForTesting()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -448,7 +448,7 @@ func TestFetchURLListSuccess(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestFetchURLListWithCC(t *testing.T) {
|
||||
sess, err := NewSession()
|
||||
sess, err := NewSessionForTesting()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue