Esempio n. 1
0
func TestMain(m *testing.M) {
	var db *sqlx.DB
	var err error
	var c dockertest.ContainerID
	if c, err = dockertest.ConnectToPostgreSQL(15, time.Second, func(url string) bool {
		var err error
		db, err = sqlx.Open("postgres", url)
		if err != nil {
			return false
		}
		return db.Ping() == nil
	}); err != nil {
		log.Fatalf("Could not connect to database: %s", err)
	}

	s = &PostgresStore{DB: db}
	if err := s.CreateSchemas(); err != nil {
		log.Fatalf("Could not set up schemas: %v", err)
	}
	if err := s.CreateSchemas(); err != nil {
		log.Fatalf("Schema did fail on second time: %v", err)
	}

	result := m.Run()
	c.KillRemove()
	os.Exit(result)
}
Esempio n. 2
0
func TestMain(m *testing.M) {
	var err error
	var c dockertest.ContainerID
	c, db, err = dockertest.OpenPostgreSQLContainerConnection(15, time.Second)
	if err != nil {
		log.Fatalf("Could not connect to database: %s", err)
	}
	defer c.KillRemove()

	ladonStore = ladon.New(db)
	if err := ladonStore.CreateSchemas(); err != nil {
		log.Fatalf("Could not set up schemas: %v", err)
	}
	os.Exit(m.Run())
}
Esempio n. 3
0
func TestMain(m *testing.M) {
	var err error
	var c dockertest.ContainerID
	c, db, err = dockertest.OpenPostgreSQLContainerConnection(15, time.Millisecond*500)
	if err != nil {
		log.Fatalf("Could not set up PostgreSQL container: %v", err)
	}
	defer c.KillRemove()

	store = New(db)
	if err = store.CreateSchemas(); err != nil {
		log.Fatalf("Could not set up schemas: %v", err)
	}

	os.Exit(m.Run())
}
Esempio n. 4
0
func cleanupTestContainer(t *testing.T, cid dockertest.ContainerID) {
	err := cid.KillRemove()
	if err != nil {
		t.Fatal(err)
	}
}