fix test on time

This commit is contained in:
Umputun
2018-05-24 20:35:43 -05:00
parent 43771edf62
commit 01ba236e40
3 changed files with 8 additions and 7 deletions
+2 -2
View File
@@ -154,10 +154,10 @@ func TestServer_RssWithReply(t *testing.T) {
func waitOnMinChange() {
for {
if time.Now().Second() != 59 {
if time.Now().Nanosecond() > 500000000 {
break
}
time.Sleep(10 * time.Millisecond)
time.Sleep(10 * time.Nanosecond)
}
}
+4 -4
View File
@@ -20,7 +20,7 @@ import (
func TestLogin(t *testing.T) {
_, ts, ots := mockProvider(t, 8981, 8982)
ts, ots := mockProvider(t, 8981, 8982)
defer func() {
ts.Close()
ots.Close()
@@ -63,7 +63,7 @@ func TestLogin(t *testing.T) {
func TestLogout(t *testing.T) {
_, ts, ots := mockProvider(t, 8691, 8692)
ts, ots := mockProvider(t, 8691, 8692)
defer func() {
ts.Close()
ots.Close()
@@ -99,7 +99,7 @@ func TestInitProvider(t *testing.T) {
assert.Equal(t, "test", res.Name)
}
func mockProvider(t *testing.T, loginPort, authPort int) (*Provider, *http.Server, *http.Server) {
func mockProvider(t *testing.T, loginPort, authPort int) (*http.Server, *http.Server) {
provider := Provider{
Name: "mock",
@@ -170,5 +170,5 @@ func mockProvider(t *testing.T, loginPort, authPort int) (*Provider, *http.Serve
go ts.ListenAndServe()
time.Sleep(time.Millisecond * 100) // let the start
return &provider, ts, oauth
return ts, oauth
}
+2 -1
View File
@@ -33,8 +33,8 @@ func TestBoltDB_CreateAndFind(t *testing.T) {
}
func TestBoltDB_Delete(t *testing.T) {
b := prep(t)
defer os.Remove(testDb)
b := prep(t)
loc := store.Locator{URL: "https://radio-t.com", SiteID: "radio-t"}
res, err := b.Find(loc, "time")
@@ -285,6 +285,7 @@ func TestBoltDB_Ref(t *testing.T) {
// makes new boltdb, put two records
func prep(t *testing.T) *BoltDB {
os.Remove(testDb)
time.Sleep(10 * time.Millisecond)
boltStore, err := NewBoltDB(bolt.Options{}, BoltSite{FileName: testDb, SiteID: "radio-t"})
assert.Nil(t, err)