ooni-probe-cli/internal/model/mocks/saver_test.go
Simone Basso d0da224a2a
feat(oonirun): improve tests (#915)
See https://github.com/ooni/probe/issues/2184

While there, rename `runtimex.PanicIfFalse` to `runtimex.Assert` (it was about time...)
2022-08-31 18:40:27 +02:00

24 lines
445 B
Go

package mocks
import (
"errors"
"testing"
"github.com/ooni/probe-cli/v3/internal/model"
)
func TestSaver(t *testing.T) {
t.Run("SaveMeasurement", func(t *testing.T) {
expected := errors.New("mocked error")
s := &Saver{
MockSaveMeasurement: func(m *model.Measurement) error {
return expected
},
}
err := s.SaveMeasurement(&model.Measurement{})
if !errors.Is(err, expected) {
t.Fatal("unexpected err", err)
}
})
}