-
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.
ensure *taskMetadata type returned from GetTaskMetadataProvider has a…
… stable interface going forward
- Loading branch information
1 parent
186b9e3
commit 39c3cf5
Showing
2 changed files
with
53 additions
and
12 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,53 @@ | ||
package loadtester | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
) | ||
|
||
func TestMetadataProviderInterfaceStability(t *testing.T) { | ||
type taskMetadataProvider interface { | ||
IntervalID() time.Time | ||
EnqueueTime() time.Time | ||
DequeueTime() time.Time | ||
SampleSize() int | ||
NumIntervalTasks() int | ||
Lag() time.Duration | ||
} | ||
|
||
now := time.Now() | ||
v := taskMetadataProvider(&taskMetadata{taskMetadataState{ | ||
meta: taskMeta{ | ||
IntervalID: now, | ||
SampleSize: 2, | ||
NumIntervalTasks: 3, | ||
Lag: 2 * time.Second, | ||
}, | ||
enqueueTime: now.Add(1 * time.Minute), | ||
dequeueTime: now.Add(2 * time.Minute), | ||
}}) | ||
|
||
if !v.IntervalID().Equal(now) { | ||
t.Fatal() | ||
} | ||
|
||
if !v.EnqueueTime().Equal(now.Add(1 * time.Minute)) { | ||
t.Fatal() | ||
} | ||
|
||
if !v.DequeueTime().Equal(now.Add(2 * time.Minute)) { | ||
t.Fatal() | ||
} | ||
|
||
if v.SampleSize() != 2 { | ||
t.Fatal() | ||
} | ||
|
||
if v.NumIntervalTasks() != 3 { | ||
t.Fatal() | ||
} | ||
|
||
if v.Lag() != 2*time.Second { | ||
t.Fatal() | ||
} | ||
} |