From 80ea29de8f316309b90a8caa68a0c95641851e8c Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Sat, 14 Dec 2013 15:15:09 +0100 Subject: [PATCH] mongo: use SKIP_DEP_TESTS again. regressed in recent refactor. Noticed because 'make presubmit' was breaking when offline. Change-Id: I1afd12eb2ae8f504018b8a30a91d2d2e87d35999 --- pkg/index/mongo/mongoindex_test.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/pkg/index/mongo/mongoindex_test.go b/pkg/index/mongo/mongoindex_test.go index a61a0a0c7..ec6bbb78e 100644 --- a/pkg/index/mongo/mongoindex_test.go +++ b/pkg/index/mongo/mongoindex_test.go @@ -40,7 +40,18 @@ func checkMongoUp() { mongoNotAvailable = !mongo.Ping("localhost", 500*time.Millisecond) } +func skipOrFailIfNoMongo(t *testing.T) { + once.Do(checkMongoUp) + if mongoNotAvailable { + err := errors.New("Not running; start a mongoDB daemon on the standard port (27017). The \"keys\" collection in the \"camlitest\" database will be used.") + test.DependencyErrorOrSkip(t) + t.Fatalf("Mongo not available locally for testing: %v", err) + } +} + func newSorted(t *testing.T) (kv sorted.KeyValue, cleanup func()) { + skipOrFailIfNoMongo(t) + // connect without credentials and wipe the database cfg := jsonconfig.Obj{ "host": "localhost", @@ -73,12 +84,7 @@ func TestSortedKV(t *testing.T) { type mongoTester struct{} func (mongoTester) test(t *testing.T, tfn func(*testing.T, func() *index.Index)) { - once.Do(checkMongoUp) - if mongoNotAvailable { - err := errors.New("Not running; start a mongoDB daemon on the standard port (27017). The \"keys\" collection in the \"camlitest\" database will be used.") - test.DependencyErrorOrSkip(t) - t.Fatalf("Mongo not available locally for testing: %v", err) - } + skipOrFailIfNoMongo(t) defer test.TLog(t)() var cleanups []func() defer func() {