コード例 #1
0
ファイル: cache_test.go プロジェクト: coddo/gost
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)
}
コード例 #2
0
func setUpTransactionsTest(t *testing.T) {
	testconfig.InitTestsDatabase()
	service.InitDbService()

	if recover() != nil {
		t.Fatal("Test setup failed!")
	}
}
コード例 #3
0
ファイル: service_test.go プロジェクト: coddo/gost
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")
	}
}
コード例 #4
0
ファイル: api_tests_aux.go プロジェクト: coddo/gost
// 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)
}