mirror of
https://github.com/compute-blade-community/compute-blade-agent.git
synced 2026-04-21 17:45:43 +02:00
feat: LedEngine for controlling LED patterns (e.g. burst blinks)
Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com>
This commit is contained in:
24
pkg/util/clock.go
Normal file
24
pkg/util/clock.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Clock is an interface for the time package
|
||||
type Clock interface {
|
||||
// Now returns the current time.
|
||||
Now() time.Time
|
||||
// After waits for the duration to elapse and then sends the current time
|
||||
After(d time.Duration) <-chan time.Time
|
||||
}
|
||||
|
||||
// RealClock implements the Clock interface using the real time package.
|
||||
type RealClock struct{}
|
||||
|
||||
func (RealClock) Now() time.Time {
|
||||
return time.Now()
|
||||
}
|
||||
|
||||
func (RealClock) After(d time.Duration) <-chan time.Time {
|
||||
return time.After(d)
|
||||
}
|
||||
24
pkg/util/clock_mock.go
Normal file
24
pkg/util/clock_mock.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// MockClock implements the Clock interface using the testify mock package.
|
||||
type MockClock struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
// Now returns the current time.
|
||||
func (mc *MockClock) Now() time.Time {
|
||||
args := mc.Called()
|
||||
return args.Get(0).(time.Time)
|
||||
}
|
||||
|
||||
// After waits for the duration to elapse and then sends the current time
|
||||
func (mc *MockClock) After(d time.Duration) <-chan time.Time {
|
||||
args := mc.Called(d)
|
||||
return args.Get(0).(chan time.Time)
|
||||
}
|
||||
Reference in New Issue
Block a user