Browse Source

move test utilities into 'test' (#3016)

* move test utilities into 'test'

* rename newEmptyTimer into emptyTimer
pull/3017/head
Alessandro Ros 1 year ago committed by GitHub
parent
commit
b6eaa6bc18
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      internal/core/api_test.go
  2. 2
      internal/core/metrics_test.go
  3. 22
      internal/core/path.go
  4. 2
      internal/core/path_test.go
  5. 2
      internal/core/static_source_handler.go
  6. 3
      internal/core/webrtc_server_test.go
  7. 11
      internal/playback/server_test.go
  8. 9
      internal/protocols/webrtc/peer_connection.go
  9. 15
      internal/record/agent_test.go
  10. 3
      internal/record/cleaner_test.go
  11. 4
      internal/servers/hls/muxer.go
  12. 4
      internal/staticsources/hls/source_test.go
  13. 8
      internal/staticsources/rtmp/source_test.go
  14. 12
      internal/staticsources/rtsp/source_test.go
  15. 4
      internal/staticsources/srt/source_test.go
  16. 4
      internal/staticsources/udp/source_test.go
  17. 5
      internal/staticsources/webrtc/source_test.go
  18. 10
      internal/test/nil_logger.go
  19. 22
      internal/test/source_tester.go

4
internal/core/api_test.go

@ -27,6 +27,7 @@ import ( @@ -27,6 +27,7 @@ import (
"github.com/bluenviron/mediamtx/internal/protocols/rtmp"
"github.com/bluenviron/mediamtx/internal/protocols/webrtc"
"github.com/bluenviron/mediamtx/internal/test"
)
var testFormatH264 = &format.H264{
@ -541,6 +542,7 @@ func TestAPIProtocolList(t *testing.T) { @@ -541,6 +542,7 @@ func TestAPIProtocolList(t *testing.T) {
c := &webrtc.WHIPClient{
HTTPClient: hc,
URL: u,
Log: test.NilLogger{},
}
_, err = c.Read(context.Background())
@ -840,6 +842,7 @@ func TestAPIProtocolGet(t *testing.T) { @@ -840,6 +842,7 @@ func TestAPIProtocolGet(t *testing.T) {
c := &webrtc.WHIPClient{
HTTPClient: hc,
URL: u,
Log: test.NilLogger{},
}
_, err = c.Read(context.Background())
@ -1134,6 +1137,7 @@ func TestAPIProtocolKick(t *testing.T) { @@ -1134,6 +1137,7 @@ func TestAPIProtocolKick(t *testing.T) {
c := &webrtc.WHIPClient{
HTTPClient: hc,
URL: u,
Log: test.NilLogger{},
}
_, err = c.Publish(context.Background(), medi.Formats[0], nil)

2
internal/core/metrics_test.go

@ -22,6 +22,7 @@ import ( @@ -22,6 +22,7 @@ import (
"github.com/bluenviron/mediamtx/internal/protocols/rtmp"
"github.com/bluenviron/mediamtx/internal/protocols/webrtc"
"github.com/bluenviron/mediamtx/internal/test"
)
func TestMetrics(t *testing.T) {
@ -158,6 +159,7 @@ webrtc_sessions_bytes_sent 0 @@ -158,6 +159,7 @@ webrtc_sessions_bytes_sent 0
s := &webrtc.WHIPClient{
HTTPClient: &http.Client{Transport: &http.Transport{}},
URL: su,
Log: test.NilLogger{},
}
tracks, err := s.Publish(context.Background(), testMediaH264.Formats[0], nil)

22
internal/core/path.go

@ -21,7 +21,7 @@ import ( @@ -21,7 +21,7 @@ import (
"github.com/bluenviron/mediamtx/internal/stream"
)
func newEmptyTimer() *time.Timer {
func emptyTimer() *time.Timer {
t := time.NewTimer(0)
<-t.C
return t
@ -122,10 +122,10 @@ func (pa *path) initialize() { @@ -122,10 +122,10 @@ func (pa *path) initialize() {
pa.ctx = ctx
pa.ctxCancel = ctxCancel
pa.readers = make(map[defs.Reader]struct{})
pa.onDemandStaticSourceReadyTimer = newEmptyTimer()
pa.onDemandStaticSourceCloseTimer = newEmptyTimer()
pa.onDemandPublisherReadyTimer = newEmptyTimer()
pa.onDemandPublisherCloseTimer = newEmptyTimer()
pa.onDemandStaticSourceReadyTimer = emptyTimer()
pa.onDemandStaticSourceCloseTimer = emptyTimer()
pa.onDemandPublisherReadyTimer = emptyTimer()
pa.onDemandPublisherCloseTimer = emptyTimer()
pa.chReloadConf = make(chan *conf.Path)
pa.chStaticSourceSetReady = make(chan defs.PathSourceStaticSetReadyReq)
pa.chStaticSourceSetNotReady = make(chan defs.PathSourceStaticSetNotReadyReq)
@ -393,7 +393,7 @@ func (pa *path) doSourceStaticSetReady(req defs.PathSourceStaticSetReadyReq) { @@ -393,7 +393,7 @@ func (pa *path) doSourceStaticSetReady(req defs.PathSourceStaticSetReadyReq) {
if pa.conf.HasOnDemandStaticSource() {
pa.onDemandStaticSourceReadyTimer.Stop()
pa.onDemandStaticSourceReadyTimer = newEmptyTimer()
pa.onDemandStaticSourceReadyTimer = emptyTimer()
pa.onDemandStaticSourceScheduleClose()
}
@ -515,7 +515,7 @@ func (pa *path) doStartPublisher(req defs.PathStartPublisherReq) { @@ -515,7 +515,7 @@ func (pa *path) doStartPublisher(req defs.PathStartPublisherReq) {
if pa.conf.HasOnDemandPublisher() && pa.onDemandPublisherState != pathOnDemandStateInitial {
pa.onDemandPublisherReadyTimer.Stop()
pa.onDemandPublisherReadyTimer = newEmptyTimer()
pa.onDemandPublisherReadyTimer = emptyTimer()
pa.onDemandPublisherScheduleClose()
}
@ -674,7 +674,7 @@ func (pa *path) onDemandStaticSourceScheduleClose() { @@ -674,7 +674,7 @@ func (pa *path) onDemandStaticSourceScheduleClose() {
func (pa *path) onDemandStaticSourceStop(reason string) {
if pa.onDemandStaticSourceState == pathOnDemandStateClosing {
pa.onDemandStaticSourceCloseTimer.Stop()
pa.onDemandStaticSourceCloseTimer = newEmptyTimer()
pa.onDemandStaticSourceCloseTimer = emptyTimer()
}
pa.onDemandStaticSourceState = pathOnDemandStateInitial
@ -707,7 +707,7 @@ func (pa *path) onDemandPublisherScheduleClose() { @@ -707,7 +707,7 @@ func (pa *path) onDemandPublisherScheduleClose() {
func (pa *path) onDemandPublisherStop(reason string) {
if pa.onDemandPublisherState == pathOnDemandStateClosing {
pa.onDemandPublisherCloseTimer.Stop()
pa.onDemandPublisherCloseTimer = newEmptyTimer()
pa.onDemandPublisherCloseTimer = emptyTimer()
}
pa.onUnDemandHook(reason)
@ -857,13 +857,13 @@ func (pa *path) addReaderPost(req defs.PathAddReaderReq) { @@ -857,13 +857,13 @@ func (pa *path) addReaderPost(req defs.PathAddReaderReq) {
if pa.onDemandStaticSourceState == pathOnDemandStateClosing {
pa.onDemandStaticSourceState = pathOnDemandStateReady
pa.onDemandStaticSourceCloseTimer.Stop()
pa.onDemandStaticSourceCloseTimer = newEmptyTimer()
pa.onDemandStaticSourceCloseTimer = emptyTimer()
}
} else if pa.conf.HasOnDemandPublisher() {
if pa.onDemandPublisherState == pathOnDemandStateClosing {
pa.onDemandPublisherState = pathOnDemandStateReady
pa.onDemandPublisherCloseTimer.Stop()
pa.onDemandPublisherCloseTimer = newEmptyTimer()
pa.onDemandPublisherCloseTimer = emptyTimer()
}
}

2
internal/core/path_test.go

@ -26,6 +26,7 @@ import ( @@ -26,6 +26,7 @@ import (
"github.com/bluenviron/mediamtx/internal/defs"
"github.com/bluenviron/mediamtx/internal/protocols/rtmp"
"github.com/bluenviron/mediamtx/internal/protocols/webrtc"
"github.com/bluenviron/mediamtx/internal/test"
)
var runOnDemandSampleScript = `
@ -400,6 +401,7 @@ func TestPathRunOnRead(t *testing.T) { @@ -400,6 +401,7 @@ func TestPathRunOnRead(t *testing.T) {
c := &webrtc.WHIPClient{
HTTPClient: hc,
URL: u,
Log: test.NilLogger{},
}
_, err = c.Read(context.Background())

2
internal/core/static_source_handler.go

@ -180,7 +180,7 @@ func (s *staticSourceHandler) run() { @@ -180,7 +180,7 @@ func (s *staticSourceHandler) run() {
recreate()
recreating := false
recreateTimer := newEmptyTimer()
recreateTimer := emptyTimer()
for {
select {

3
internal/core/webrtc_server_test.go

@ -17,6 +17,7 @@ import ( @@ -17,6 +17,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/bluenviron/mediamtx/internal/protocols/webrtc"
"github.com/bluenviron/mediamtx/internal/test"
)
func TestWebRTCPages(t *testing.T) {
@ -144,6 +145,7 @@ func TestWebRTCRead(t *testing.T) { @@ -144,6 +145,7 @@ func TestWebRTCRead(t *testing.T) {
c := &webrtc.WHIPClient{
HTTPClient: hc,
URL: u,
Log: test.NilLogger{},
}
tracks, err := c.Read(context.Background())
@ -284,6 +286,7 @@ func TestWebRTCPublish(t *testing.T) { @@ -284,6 +286,7 @@ func TestWebRTCPublish(t *testing.T) {
s := &webrtc.WHIPClient{
HTTPClient: hc,
URL: su,
Log: test.NilLogger{},
}
tracks, err := s.Publish(context.Background(), testMediaH264.Formats[0], nil)

11
internal/playback/server_test.go

@ -13,15 +13,10 @@ import ( @@ -13,15 +13,10 @@ import (
"github.com/bluenviron/mediacommon/pkg/formats/fmp4"
"github.com/bluenviron/mediacommon/pkg/formats/fmp4/seekablebuffer"
"github.com/bluenviron/mediamtx/internal/conf"
"github.com/bluenviron/mediamtx/internal/logger"
"github.com/bluenviron/mediamtx/internal/test"
"github.com/stretchr/testify/require"
)
type nilLogger struct{}
func (nilLogger) Log(_ logger.Level, _ string, _ ...interface{}) {
}
func writeSegment1(t *testing.T, fpath string) {
init := fmp4.Init{
Tracks: []*fmp4.InitTrack{{
@ -155,7 +150,7 @@ func TestServerGet(t *testing.T) { @@ -155,7 +150,7 @@ func TestServerGet(t *testing.T) {
RecordPath: filepath.Join(dir, "%path/%Y-%m-%d_%H-%M-%S-%f"),
},
},
Parent: &nilLogger{},
Parent: &test.NilLogger{},
}
err = s.Initialize()
require.NoError(t, err)
@ -249,7 +244,7 @@ func TestServerList(t *testing.T) { @@ -249,7 +244,7 @@ func TestServerList(t *testing.T) {
RecordPath: filepath.Join(dir, "%path/%Y-%m-%d_%H-%M-%S-%f"),
},
},
Parent: &nilLogger{},
Parent: &test.NilLogger{},
}
err = s.Initialize()
require.NoError(t, err)

9
internal/protocols/webrtc/peer_connection.go

@ -19,11 +19,6 @@ const ( @@ -19,11 +19,6 @@ const (
webrtcStreamID = "mediamtx"
)
type nilLogger struct{}
func (nilLogger) Log(_ logger.Level, _ string, _ ...interface{}) {
}
type trackRecvPair struct {
track *webrtc.TrackRemote
receiver *webrtc.RTPReceiver
@ -48,10 +43,6 @@ type PeerConnection struct { @@ -48,10 +43,6 @@ type PeerConnection struct {
// Start starts the peer connection.
func (co *PeerConnection) Start() error {
if co.Log == nil {
co.Log = &nilLogger{}
}
configuration := webrtc.Configuration{
ICEServers: co.ICEServers,
}

15
internal/record/agent_test.go

@ -11,19 +11,14 @@ import ( @@ -11,19 +11,14 @@ import (
"github.com/bluenviron/mediacommon/pkg/codecs/h265"
"github.com/bluenviron/mediacommon/pkg/codecs/mpeg4audio"
"github.com/bluenviron/mediacommon/pkg/formats/fmp4"
"github.com/bluenviron/mediamtx/internal/logger"
"github.com/stretchr/testify/require"
"github.com/bluenviron/mediamtx/internal/conf"
"github.com/bluenviron/mediamtx/internal/stream"
"github.com/bluenviron/mediamtx/internal/test"
"github.com/bluenviron/mediamtx/internal/unit"
)
type nilLogger struct{}
func (nilLogger) Log(_ logger.Level, _ string, _ ...interface{}) {
}
func TestAgent(t *testing.T) {
desc := &description.Session{Medias: []*description.Media{
{
@ -149,7 +144,7 @@ func TestAgent(t *testing.T) { @@ -149,7 +144,7 @@ func TestAgent(t *testing.T) {
1460,
desc,
true,
&nilLogger{},
&test.NilLogger{},
)
require.NoError(t, err)
defer stream.Close()
@ -184,7 +179,7 @@ func TestAgent(t *testing.T) { @@ -184,7 +179,7 @@ func TestAgent(t *testing.T) {
OnSegmentComplete: func(fpath string) {
segDone <- struct{}{}
},
Parent: &nilLogger{},
Parent: &test.NilLogger{},
restartPause: 1 * time.Millisecond,
}
w.Initialize()
@ -265,7 +260,7 @@ func TestAgentFMP4NegativeDTS(t *testing.T) { @@ -265,7 +260,7 @@ func TestAgentFMP4NegativeDTS(t *testing.T) {
1460,
desc,
true,
&nilLogger{},
&test.NilLogger{},
)
require.NoError(t, err)
defer stream.Close()
@ -284,7 +279,7 @@ func TestAgentFMP4NegativeDTS(t *testing.T) { @@ -284,7 +279,7 @@ func TestAgentFMP4NegativeDTS(t *testing.T) {
SegmentDuration: 1 * time.Second,
PathName: "mypath",
Stream: stream,
Parent: &nilLogger{},
Parent: &test.NilLogger{},
}
w.Initialize()

3
internal/record/cleaner_test.go

@ -7,6 +7,7 @@ import ( @@ -7,6 +7,7 @@ import (
"time"
"github.com/bluenviron/mediamtx/internal/conf"
"github.com/bluenviron/mediamtx/internal/test"
"github.com/stretchr/testify/require"
)
@ -36,7 +37,7 @@ func TestCleaner(t *testing.T) { @@ -36,7 +37,7 @@ func TestCleaner(t *testing.T) {
Format: conf.RecordFormatFMP4,
DeleteAfter: 10 * time.Second,
}},
Parent: nilLogger{},
Parent: test.NilLogger{},
}
c.Initialize()
defer c.Close()

4
internal/servers/hls/muxer.go

@ -34,7 +34,7 @@ func int64Ptr(v int64) *int64 { @@ -34,7 +34,7 @@ func int64Ptr(v int64) *int64 {
return &v
}
func newEmptyTimer() *time.Timer {
func emptyTimer() *time.Timer {
t := time.NewTimer(0)
<-t.C
return t
@ -142,7 +142,7 @@ func (m *muxer) run() { @@ -142,7 +142,7 @@ func (m *muxer) run() {
isReady := false
isRecreating := false
recreateTimer := newEmptyTimer()
recreateTimer := emptyTimer()
for {
select {

4
internal/staticsources/hls/source_test.go

@ -13,7 +13,7 @@ import ( @@ -13,7 +13,7 @@ import (
"github.com/bluenviron/mediamtx/internal/conf"
"github.com/bluenviron/mediamtx/internal/defs"
"github.com/bluenviron/mediamtx/internal/staticsources/tester"
"github.com/bluenviron/mediamtx/internal/test"
)
func TestSource(t *testing.T) {
@ -86,7 +86,7 @@ func TestSource(t *testing.T) { @@ -86,7 +86,7 @@ func TestSource(t *testing.T) {
go s.Serve(ln)
defer s.Shutdown(context.Background())
te := tester.New(
te := test.NewSourceTester(
func(p defs.StaticSourceParent) defs.StaticSource {
return &Source{
ResolvedSource: "http://localhost:5780/stream.m3u8",

8
internal/staticsources/rtmp/source_test.go

@ -14,7 +14,7 @@ import ( @@ -14,7 +14,7 @@ import (
"github.com/bluenviron/mediamtx/internal/conf"
"github.com/bluenviron/mediamtx/internal/defs"
"github.com/bluenviron/mediamtx/internal/protocols/rtmp"
"github.com/bluenviron/mediamtx/internal/staticsources/tester"
"github.com/bluenviron/mediamtx/internal/test"
)
var serverCert = []byte(`-----BEGIN CERTIFICATE-----
@ -150,10 +150,10 @@ func TestSource(t *testing.T) { @@ -150,10 +150,10 @@ func TestSource(t *testing.T) {
require.NoError(t, err)
}()
var te *tester.Tester
var te *test.SourceTester
if ca == "plain" {
te = tester.New(
te = test.NewSourceTester(
func(p defs.StaticSourceParent) defs.StaticSource {
return &Source{
ResolvedSource: "rtmp://localhost/teststream",
@ -165,7 +165,7 @@ func TestSource(t *testing.T) { @@ -165,7 +165,7 @@ func TestSource(t *testing.T) {
&conf.Path{},
)
} else {
te = tester.New(
te = test.NewSourceTester(
func(p defs.StaticSourceParent) defs.StaticSource {
return &Source{
ResolvedSource: "rtmps://localhost/teststream",

12
internal/staticsources/rtsp/source_test.go

@ -16,7 +16,7 @@ import ( @@ -16,7 +16,7 @@ import (
"github.com/bluenviron/mediamtx/internal/conf"
"github.com/bluenviron/mediamtx/internal/defs"
"github.com/bluenviron/mediamtx/internal/staticsources/tester"
"github.com/bluenviron/mediamtx/internal/test"
)
var serverCert = []byte(`-----BEGIN CERTIFICATE-----
@ -206,13 +206,13 @@ func TestSource(t *testing.T) { @@ -206,13 +206,13 @@ func TestSource(t *testing.T) {
stream = gortsplib.NewServerStream(&s, &description.Session{Medias: []*description.Media{testMediaH264}})
defer stream.Close()
var te *tester.Tester
var te *test.SourceTester
if source != "tls" {
var sp conf.RTSPTransport
sp.UnmarshalJSON([]byte(`"` + source + `"`)) //nolint:errcheck
te = tester.New(
te = test.NewSourceTester(
func(p defs.StaticSourceParent) defs.StaticSource {
return &Source{
ResolvedSource: "rtsp://testuser:testpass@localhost:8555/teststream",
@ -227,7 +227,7 @@ func TestSource(t *testing.T) { @@ -227,7 +227,7 @@ func TestSource(t *testing.T) {
},
)
} else {
te = tester.New(
te = test.NewSourceTester(
func(p defs.StaticSourceParent) defs.StaticSource {
return &Source{
ResolvedSource: "rtsps://testuser:testpass@localhost:8555/teststream",
@ -313,7 +313,7 @@ func TestRTSPSourceNoPassword(t *testing.T) { @@ -313,7 +313,7 @@ func TestRTSPSourceNoPassword(t *testing.T) {
var sp conf.RTSPTransport
sp.UnmarshalJSON([]byte(`"tcp"`)) //nolint:errcheck
te := tester.New(
te := test.NewSourceTester(
func(p defs.StaticSourceParent) defs.StaticSource {
return &Source{
ResolvedSource: "rtsp://testuser:@127.0.0.1:8555/teststream",
@ -408,7 +408,7 @@ func TestRTSPSourceRange(t *testing.T) { @@ -408,7 +408,7 @@ func TestRTSPSourceRange(t *testing.T) {
cnf.RTSPRangeStart = "130s"
}
te := tester.New(
te := test.NewSourceTester(
func(p defs.StaticSourceParent) defs.StaticSource {
return &Source{
ResolvedSource: "rtsp://127.0.0.1:8555/teststream",

4
internal/staticsources/srt/source_test.go

@ -11,7 +11,7 @@ import ( @@ -11,7 +11,7 @@ import (
"github.com/bluenviron/mediamtx/internal/conf"
"github.com/bluenviron/mediamtx/internal/defs"
"github.com/bluenviron/mediamtx/internal/staticsources/tester"
"github.com/bluenviron/mediamtx/internal/test"
)
func TestSource(t *testing.T) {
@ -56,7 +56,7 @@ func TestSource(t *testing.T) { @@ -56,7 +56,7 @@ func TestSource(t *testing.T) {
time.Sleep(1000 * time.Millisecond)
}()
te := tester.New(
te := test.NewSourceTester(
func(p defs.StaticSourceParent) defs.StaticSource {
return &Source{
ResolvedSource: "srt://localhost:9002?streamid=sidname&passphrase=ttest1234567",

4
internal/staticsources/udp/source_test.go

@ -11,11 +11,11 @@ import ( @@ -11,11 +11,11 @@ import (
"github.com/bluenviron/mediamtx/internal/conf"
"github.com/bluenviron/mediamtx/internal/defs"
"github.com/bluenviron/mediamtx/internal/staticsources/tester"
"github.com/bluenviron/mediamtx/internal/test"
)
func TestSource(t *testing.T) {
te := tester.New(
te := test.NewSourceTester(
func(p defs.StaticSourceParent) defs.StaticSource {
return &Source{
ResolvedSource: "udp://localhost:9001",

5
internal/staticsources/webrtc/source_test.go

@ -16,7 +16,7 @@ import ( @@ -16,7 +16,7 @@ import (
"github.com/bluenviron/mediamtx/internal/conf"
"github.com/bluenviron/mediamtx/internal/defs"
"github.com/bluenviron/mediamtx/internal/protocols/webrtc"
"github.com/bluenviron/mediamtx/internal/staticsources/tester"
"github.com/bluenviron/mediamtx/internal/test"
)
func whipOffer(body []byte) *pwebrtc.SessionDescription {
@ -36,6 +36,7 @@ func TestSource(t *testing.T) { @@ -36,6 +36,7 @@ func TestSource(t *testing.T) {
pc := &webrtc.PeerConnection{
API: api,
Publish: true,
Log: test.NilLogger{},
}
err = pc.Start()
require.NoError(t, err)
@ -124,7 +125,7 @@ func TestSource(t *testing.T) { @@ -124,7 +125,7 @@ func TestSource(t *testing.T) {
go httpServ.Serve(ln)
defer httpServ.Shutdown(context.Background())
te := tester.New(
te := test.NewSourceTester(
func(p defs.StaticSourceParent) defs.StaticSource {
return &Source{
ResolvedSource: "whep://localhost:9003/my/resource",

10
internal/test/nil_logger.go

@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
package test
import "github.com/bluenviron/mediamtx/internal/logger"
// NilLogger is a logger to /dev/null
type NilLogger struct{}
// Log implements logger.Writer.
func (NilLogger) Log(_ logger.Level, _ string, _ ...interface{}) {
}

22
internal/staticsources/tester/tester.go → internal/test/source_tester.go

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
// Package tester contains a static source tester.
package tester
// Package test contains test utilities.
package test
import (
"context"
@ -12,8 +12,8 @@ import ( @@ -12,8 +12,8 @@ import (
"github.com/bluenviron/mediamtx/internal/unit"
)
// Tester is a static source tester.
type Tester struct {
// SourceTester is a static source tester.
type SourceTester struct {
ctx context.Context
ctxCancel func()
stream *stream.Stream
@ -23,11 +23,11 @@ type Tester struct { @@ -23,11 +23,11 @@ type Tester struct {
done chan struct{}
}
// New allocates a tester.
func New(createFunc func(defs.StaticSourceParent) defs.StaticSource, conf *conf.Path) *Tester {
// NewSourceTester allocates a SourceTester.
func NewSourceTester(createFunc func(defs.StaticSourceParent) defs.StaticSource, conf *conf.Path) *SourceTester {
ctx, ctxCancel := context.WithCancel(context.Background())
t := &Tester{
t := &SourceTester{
ctx: ctx,
ctxCancel: ctxCancel,
Unit: make(chan unit.Unit),
@ -48,7 +48,7 @@ func New(createFunc func(defs.StaticSourceParent) defs.StaticSource, conf *conf. @@ -48,7 +48,7 @@ func New(createFunc func(defs.StaticSourceParent) defs.StaticSource, conf *conf.
}
// Close closes the tester.
func (t *Tester) Close() {
func (t *SourceTester) Close() {
t.ctxCancel()
t.writer.Stop()
t.stream.Close()
@ -56,11 +56,11 @@ func (t *Tester) Close() { @@ -56,11 +56,11 @@ func (t *Tester) Close() {
}
// Log implements StaticSourceParent.
func (t *Tester) Log(_ logger.Level, _ string, _ ...interface{}) {
func (t *SourceTester) Log(_ logger.Level, _ string, _ ...interface{}) {
}
// SetReady implements StaticSourceParent.
func (t *Tester) SetReady(req defs.PathSourceStaticSetReadyReq) defs.PathSourceStaticSetReadyRes {
func (t *SourceTester) SetReady(req defs.PathSourceStaticSetReadyReq) defs.PathSourceStaticSetReadyRes {
t.stream, _ = stream.New(
1460,
req.Desc,
@ -82,5 +82,5 @@ func (t *Tester) SetReady(req defs.PathSourceStaticSetReadyReq) defs.PathSourceS @@ -82,5 +82,5 @@ func (t *Tester) SetReady(req defs.PathSourceStaticSetReadyReq) defs.PathSourceS
}
// SetNotReady implements StaticSourceParent.
func (t *Tester) SetNotReady(_ defs.PathSourceStaticSetNotReadyReq) {
func (t *SourceTester) SetNotReady(_ defs.PathSourceStaticSetNotReadyReq) {
}
Loading…
Cancel
Save