feat(session): expose CheckIn method (#266)

* feat(session): expose CheckIn method

It seems to me the right thing to do is to query the CheckIn API
from the Session rather than querying it from InputLoader.

Then, InputLoader could just take a reference to a Session-like
interface that allows this functionality.

So, this diff exposes the Session.CheckIn method.

Doing that, in turn, required some refactoring to allow for
more and better unit tests.

While doing that, I also noticed that Session required a mutex
to be a well-behaving type, so I did that.

While doing that, I also tried to cover all the lines in session.go
and, as part of that, I have removed unused code.

Reference issue: https://github.com/ooni/probe/issues/1299.

* fix: reinstate comment I shan't have removed

* fix: repair broken test

* fix: a bit more coverage, annotations, etc.

* Update internal/engine/session.go

* Update internal/engine/session_integration_test.go

* Update internal/engine/session_internal_test.go
This commit is contained in:
Simone Basso 2021-03-29 15:04:41 +02:00 committed by GitHub
commit e0b0dfedc1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 441 additions and 69 deletions

View file

@ -1,4 +1,4 @@
// Package engine contains the engine API
// Package engine contains the engine API.
package engine
import (
@ -188,10 +188,7 @@ func (e *Experiment) OpenReportContext(ctx context.Context) error {
Counter: e.byteCounter,
},
}
if e.session.selectedProbeService == nil {
return errors.New("no probe services selected")
}
client, err := probeservices.NewClient(e.session, *e.session.selectedProbeService)
client, err := e.session.NewProbeServicesClient(ctx)
if err != nil {
e.session.logger.Debugf("%+v", err)
return err