File
Blob: spec/mocks/rtt.go
| 1 | //go:build !no_mocks |
| 2 | |
| 3 | package mocks |
| 4 | |
| 5 | import ( |
| 6 | "time" |
| 7 | |
| 8 | "go.miragespace.co/specter/spec/rtt" |
| 9 | |
| 10 | "github.com/stretchr/testify/mock" |
| 11 | ) |
| 12 | |
| 13 | type Measurement struct { |
| 14 | mock.Mock |
| 15 | } |
| 16 | |
| 17 | func (m *Measurement) Snapshot(key string, past time.Duration) *rtt.Statistics { |
| 18 | args := m.Called(key, past) |
| 19 | s := args.Get(0) |
| 20 | if s == nil { |
| 21 | return nil |
| 22 | } |
| 23 | return s.(*rtt.Statistics) |
| 24 | } |
| 25 | |
| 26 | func (m *Measurement) RecordLatency(key string, latency float64) { |
| 27 | m.Called(key, latency) |
| 28 | } |
| 29 | |
| 30 | func (m *Measurement) RecordSent(key string) { |
| 31 | m.Called(key) |
| 32 | } |
| 33 | |
| 34 | func (m *Measurement) RecordLost(key string) { |
| 35 | m.Called(key) |
| 36 | } |
| 37 | |
| 38 | func (m *Measurement) Drop(key string) { |
| 39 | m.Called(key) |
| 40 | } |
| 41 | |
| 42 | var _ rtt.Recorder = (*Measurement)(nil) |