ooni-probe-cli/pkg/oonimkall/webconnectivity_integration_test.go
Simone Basso 0f61778e7a
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
2021-03-18 08:44:58 +01:00

29 lines
637 B
Go

package oonimkall_test
import (
"testing"
"github.com/ooni/probe-cli/v3/pkg/oonimkall"
)
func TestSessionWebConnectivity(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
sess, err := NewSessionForTesting()
if err != nil {
t.Fatal(err)
}
ctx := sess.NewContext()
config := &oonimkall.WebConnectivityConfig{
Input: "https://www.google.com",
}
results, err := sess.WebConnectivity(ctx, config)
if err != nil {
t.Fatal(err)
}
t.Logf("bytes received: %f", results.KibiBytesReceived)
t.Logf("bytes sent: %f", results.KibiBytesSent)
t.Logf("measurement: %d bytes", len(results.Measurement))
}