Files
akvorado/common/daemon/tests.go
Vincent Bernat 78fb01c223 chore: fix some small issues detected by golangci-lint
But not using it as some linters are either plain incorrect (the one
suggesting to not use nil for `c.t.Context()`) or just
debatable (checking for err value is a good practice, but there are
good reasons to opt out in some cases).
2022-08-10 17:44:32 +02:00

44 lines
801 B
Go

// SPDX-FileCopyrightText: 2022 Free Mobile
// SPDX-License-Identifier: AGPL-3.0-only
//go:build !release
package daemon
import (
"testing"
"gopkg.in/tomb.v2"
)
// MockComponent is a daemon component that does nothing. It doesn't
// need to be started to work.
type MockComponent struct {
lifecycleComponent
}
// NewMock will create a daemon component that does nothing.
func NewMock(t *testing.T) Component {
t.Helper()
return &MockComponent{
lifecycleComponent: lifecycleComponent{
terminateChannel: make(chan struct{}),
},
}
}
// Start does nothing.
func (c *MockComponent) Start() error {
return nil
}
// Stop does nothing.
func (c *MockComponent) Stop() error {
c.Terminate()
return nil
}
// Track does nothing
func (c *MockComponent) Track(t *tomb.Tomb, who string) {
}