mirror of
https://github.com/grafana/grafana.git
synced 2024-11-30 04:34:23 -06:00
02f8e99ca1
* make fake storage public * move fake storages to store package
34 lines
958 B
Go
34 lines
958 B
Go
package schedule
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// waitForTimeChannel blocks the execution until either the channel ch has some data or a timeout of 10 second expires.
|
|
// Timeout will cause the test to fail.
|
|
// Returns the data from the channel.
|
|
func waitForTimeChannel(t *testing.T, ch chan time.Time) time.Time {
|
|
select {
|
|
case result := <-ch:
|
|
return result
|
|
case <-time.After(time.Duration(10) * time.Second):
|
|
t.Fatalf("Timeout waiting for data in the time channel")
|
|
return time.Time{}
|
|
}
|
|
}
|
|
|
|
// waitForErrChannel blocks the execution until either the channel ch has some data or a timeout of 10 second expires.
|
|
// Timeout will cause the test to fail.
|
|
// Returns the data from the channel.
|
|
func waitForErrChannel(t *testing.T, ch chan error) error {
|
|
timeout := time.Duration(10) * time.Second
|
|
select {
|
|
case result := <-ch:
|
|
return result
|
|
case <-time.After(timeout):
|
|
t.Fatal("Timeout waiting for data in the error channel")
|
|
return nil
|
|
}
|
|
}
|