Merge: Mock Github API tests
[nit.git] / contrib / nitrpg / src / test_helper.nit
index 1ac8314..9d71ca3 100644 (file)
 # limitations under the License.
 
 # Test tools for NitRPG.
-module test_helper is test_suite
+module test_helper
 
-import test_suite
 import game
 import github::cache
 
 # Used to factorize test treatments.
 abstract class NitrpgTestHelper
-       super TestSuite
 
        # Github API client
        var api: GithubAPI do
@@ -33,7 +31,7 @@ abstract class NitrpgTestHelper
        end
 
        # Mongo API client
-       var mongo = new MongoClient("mongodb://localhost:27017/")
+       var mongo = new MongoClient("mongodb://mongo:27017/")
 
        # Load a new test database by with a name
        private fun load_db(name: String): MongoDb do return mongo.database(name)
@@ -57,7 +55,8 @@ abstract class NitrpgTestHelper
 
        # Gen a test db with a random name (to avoid race conditions).
        fun gen_test_db: MongoDb do
-               var db_name = "test_nitrpg_{get_time}_{1000.rand}"
+               var testid = "NIT_TESTING_ID".environ.to_i
+               var db_name = "test_nitrpg_{testid}"
                var db = load_db(db_name)
                test_dbs.add db
                return db
@@ -69,5 +68,6 @@ abstract class NitrpgTestHelper
                db.drop
        end
 
-       redef fun after_test do drop_test_db
+       # Drop the databse after each test
+       fun after_test is after do drop_test_db
 end