forked from lightningnetwork/lnd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lnmock: add new package
lnmock
to host mocks
This commit introduces a new package to host mocked objects that can be used for all the unit tests.
- Loading branch information
1 parent
31a40ab
commit 5e6f10c
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// NOTE: forcetypeassert is skipped for the mock because the test would fail if | ||
// the returned value doesn't match the type. | ||
package lnmock | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/lightningnetwork/lnd/clock" | ||
"github.com/stretchr/testify/mock" | ||
) | ||
|
||
// MockClock implements the `clock.Clock` interface. | ||
type MockClock struct { | ||
mock.Mock | ||
} | ||
|
||
// Compile time assertion that MockClock implements clock.Clock. | ||
var _ clock.Clock = (*MockClock)(nil) | ||
|
||
func (m *MockClock) Now() time.Time { | ||
args := m.Called() | ||
|
||
return args.Get(0).(time.Time) | ||
} | ||
|
||
func (m *MockClock) TickAfter(d time.Duration) <-chan time.Time { | ||
args := m.Called(d) | ||
|
||
return args.Get(0).(chan time.Time) | ||
} |