Ejemplo n.º 1
0
// runTest initializes the environment for the tests and allows for
// the proper return code if the test fails or succeeds.
func runTest(m *testing.M) int {

	// Initialize the configuration and logging systems. Plus anything
	// else the web app layer needs.
	tests.Init("XENIA")

	// Initialize MongoDB using the `tests.TestSession` as the name of the
	// master session.
	if err := db.RegMasterSession(tests.Context, tests.TestSession, cfg.MustURL("MONGO_URI").String(), 0); err != nil {
		fmt.Println("Can't register master session: " + err.Error())
		return 1
	}

	db, err := db.NewMGO(tests.Context, tests.TestSession)
	if err != nil {
		fmt.Println("MongoDB is not configured")
		return 1
	}
	defer db.CloseMGO(tests.Context)

	if err := loadTestData(tests.Context, db); err != nil {
		fmt.Println("test data is not loaded: " + err.Error())
		return 1
	}
	defer unloadTestData(tests.Context, db)

	return m.Run()
}
Ejemplo n.º 2
0
// runTest initializes the environment for the tests and allows for
// the proper return code if the test fails or succeeds.
func runTest(m *testing.M) int {

	// Initialize the configuration and logging systems. Plus anything
	// else the web app layer needs.
	tests.Init("ASK")

	// Initialize MongoDB using the `tests.TestSession` as the name of the
	// master session.
	if err := db.RegMasterSession(tests.Context, tests.TestSession, cfg.MustURL("MONGO_URI").String(), 0); err != nil {
		fmt.Println("Can't register master session: " + err.Error())
		return 1
	}

	db, err := db.NewMGO(tests.Context, tests.TestSession)
	if err != nil {
		log.Fatalf("Should be able to get a Mongo session : %v", err)
	}
	defer db.CloseMGO(tests.Context)

	// We need the database indexes setup before we can call anything, so do this
	// first. This is fairly important, so we want to fail the entire test suite
	// if we can't setup the indexes.
	if err := submission.EnsureIndexes(tests.Context, db); err != nil {
		log.Fatal("Can't ensure the database indexes")
	}

	return m.Run()
}
Ejemplo n.º 3
0
// runTest initializes the environment for the tests and allows for
// the proper return code if the test fails or succeeds.
func runTest(m *testing.M) int {

	// Initialize the configuration and logging systems. Plus anything
	// else the web app layer needs.
	tests.Init("XENIA")

	// Initialize MongoDB using the `tests.TestSession` as the name of the
	// master session.
	if err := db.RegMasterSession(tests.Context, tests.TestSession, cfg.MustURL("MONGO_URI").String(), 0); err != nil {
		fmt.Println("Can't register master session: " + err.Error())
		return 1
	}

	return m.Run()
}
Ejemplo n.º 4
0
func init() {
	os.Setenv("KIT_LOGGING_LEVEL", "1")

	cfg := mongo.Config{
		Host:     "ds027155.mongolab.com:27155",
		AuthDB:   "kit",
		DB:       "kit",
		User:     "******",
		Password: "******",
	}

	tests.Init("KIT")
	tests.InitMongo(cfg)

	ensureIndexes()
}
Ejemplo n.º 5
0
func init() {
	tests.Init("KIT")
}
Ejemplo n.º 6
0
func init() {

	// Initialize the configuration and logging systems. Plus anything
	// else the web app layer needs.
	tests.Init("XENIA")
}