Skip to content

Commit

Permalink
cshared: test: Use TestMain as setup function per tests
Browse files Browse the repository at this point in the history
Signed-off-by: Hiroshi Hatake <[email protected]>
  • Loading branch information
cosmo0920 committed Oct 26, 2023
1 parent 8dbb935 commit f3c8347
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions cshared_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ func init() {
registerWG.Done()
}

func TestInputCallbackCtrlC(t *testing.T) {
func TestMain(m *testing.M) {
defer flbPluginReset()
m.Run()
}

func TestInputCallbackCtrlC(t *testing.T) {
theInputLock.Lock()
theInput = testPluginInputCallbackCtrlC{}
theInputLock.Unlock()
Expand Down Expand Up @@ -83,8 +86,6 @@ func (t testPluginInputCallbackDangle) Collect(ctx context.Context, ch chan<- Me
// Collect multiple times. This is inline with backward-compatible
// behavior.
func TestInputCallbackDangle(t *testing.T) {
defer flbPluginReset()

theInputLock.Lock()
theInput = testPluginInputCallbackDangle{}
theInputLock.Unlock()
Expand Down Expand Up @@ -158,8 +159,6 @@ func (t testPluginInputCallbackInfinite) Collect(ctx context.Context, ch chan<-
// TestInputCallbackInfinite is a test for the main method most plugins
// use where they do not return from the first invocation of collect.
func TestInputCallbackInfinite(t *testing.T) {
defer flbPluginReset()

theInputLock.Lock()
theInput = testPluginInputCallbackInfinite{}
theInputLock.Unlock()
Expand Down Expand Up @@ -246,8 +245,6 @@ func (t testPluginInputCallbackLatency) Collect(ctx context.Context, ch chan<- M
// TestInputCallbackInfiniteLatency is a test of the latency between
// messages.
func TestInputCallbackLatency(t *testing.T) {
defer flbPluginReset()

theInputLock.Lock()
theInput = testPluginInputCallbackLatency{}
theInputLock.Unlock()
Expand Down Expand Up @@ -377,8 +374,6 @@ func (t testInputCallbackInfiniteConcurrent) Collect(ctx context.Context, ch cha
// TestInputCallbackInfiniteConcurrent is meant to make sure we do not
// break anythin with respect to concurrent ingest.
func TestInputCallbackInfiniteConcurrent(t *testing.T) {
defer flbPluginReset()

theInputLock.Lock()
theInput = testInputCallbackInfiniteConcurrent{}
theInputLock.Unlock()
Expand Down

0 comments on commit f3c8347

Please sign in to comment.