29 lines
545 B
Go
29 lines
545 B
Go
package mock
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
// MockMarking implements marking.MarkingInterface with simulated marking.
|
|
type MockMarking struct {
|
|
delay time.Duration
|
|
}
|
|
|
|
// NewMockMarking creates a MockMarking with default 500ms delay.
|
|
func NewMockMarking() *MockMarking {
|
|
return &MockMarking{
|
|
delay: 500 * time.Millisecond,
|
|
}
|
|
}
|
|
|
|
// Mark simulates laser marking with a delay.
|
|
func (m *MockMarking) Mark(ctx context.Context, text string) error {
|
|
select {
|
|
case <-time.After(m.delay):
|
|
return nil
|
|
case <-ctx.Done():
|
|
return ctx.Err()
|
|
}
|
|
}
|