Ejemplo n.º 1
0
func TestCache(t *testing.T) {
	const cacheExpireTime = time.Millisecond * 700

	var cacheKeys = []combinedKey{
		combinedKey{Key: "/testKey1", DataKey: "testDataKey1"},
		combinedKey{Key: "/testKey2", DataKey: "testDataKey2"},
		combinedKey{Key: "/testTheThirdKey", DataKey: "testTheThirdDataKey"},
		combinedKey{Key: "/thisNeedsToExpire", DataKey: "thisNeedsToDataExpire"},
	}

	var items []cacheTest
	var cachedItems []*Cache
	var expiringItem *Cache

	testconfig.InitTestsDatabase()
	StartCachingSystem(cacheExpireTime)
	defer StopCachingSystem()

	items = testInitItems(t)

	testFetchInexistentCache(t, cacheKeys[0])
	cachedItems, expiringItem = testAddingToCache(t, items, cacheKeys)
	testFetchingFromCache(t, cachedItems)
	testRemovingFromCache(t, cachedItems)
	testFetchInexistentCache(t, cacheKeys[1])
	testExpiringItem(t, expiringItem, cacheExpireTime)
}
Ejemplo n.º 2
0
func setUpTransactionsTest(t *testing.T) {
	testconfig.InitTestsDatabase()
	service.InitDbService()

	if recover() != nil {
		t.Fatal("Test setup failed!")
	}
}
Ejemplo n.º 3
0
func TestServiceBase(t *testing.T) {
	testconfig.InitTestsDatabase()
	InitDbService()

	sess, col := Connect("testCollection")
	if sess == nil || col == nil {
		t.Fatal("Cannot connect to the mongodb service")
	}
}
Ejemplo n.º 4
0
// InitializeServerConfigurations initializes the HTTP/HTTPS server used for unit testing
func InitializeServerConfigurations(apiInterface interface{}) {
	testconfig.InitTestsApp()

	testconfig.InitTestsDatabase()
	testconfig.InitTestsRoutes()

	service.InitDbService()

	httphandle.RegisterEndpoints(apiInterface)

	runtime.GOMAXPROCS(2)
}