示例#1
0
func (suite *EventsTestSuite) SetupTest() {
	suite.InitTestConfig()
	suite.log = logger.Log("events_test")

	var (
		d          directory.Directory
		events     *EventsService
		subscriber *MockSubscriber
	)

	events = NewEvents().(*EventsService)
	subscriber = newMockSubscriber().(*MockSubscriber)

	d = directory.New()
	d.AddService("configProvider", suite.ConfigProvider)
	d.AddService("eventSubscriber", subscriber)
	d.AddService("events", events)

	if err := d.Start(); err != nil {
		suite.log.Fatalf("Could not start directory: %v", err)
	}

	suite.events = events
	suite.mockSubscriber = subscriber

	suite.events.ResetTestDB()
}
示例#2
0
// SetupTest prepares the test suite for running by making a fake system
// query service, providing it to a real client query service (the one we
// are testing)
func (suite *ClientQueriesTestSuite) SetupTest() {
	suite.log = logger.Log("client_test")
	var (
		d directory.Directory

		systemQueries MockSystemQueries
		clientQueries ClientQueryService
		mockUsers     MockUsers
	)

	systemQueries.complete = true

	// Set up a directory with:
	//  - A real ClientQueryService (The one we are testing)
	//  - The mocked SystemQueries implementation
	d = directory.New()
	d.AddService("clientQueries", &clientQueries)
	d.AddService("systemQueries", &systemQueries)
	d.AddService("users", &mockUsers)

	// Populate the directory so that clientQueries knows to use our mocked
	// systemQueries
	if err := d.Start(); err != nil {
		suite.log.Fatalf("Could not start directory (%v)", err)
	}

	// Store references for use in tests
	suite.mockSystemQueries = &systemQueries
	suite.clientQueries = &clientQueries
	suite.mockUsers = &mockUsers
}
示例#3
0
func (suite *ConfigTestSuite) TestProvide() {
	var (
		d directory.Directory = directory.New()
	)

	cfg := NewConfigProvider("testconfig", "../").(*viperProvider)

	d.AddService("configProvider", cfg)
	d.AddService("cacheService", &cacheService{})

	err := d.Start()

	assert := assert.New(suite.T())
	assert.Nil(err, "Unable to populate queries cache config")
}
示例#4
0
func (suite *QueriesCacheTestSuite) SetupTest() {
	suite.InitTestConfig()
	suite.log = logger.Log("cache_test")

	var (
		d     directory.Directory
		cache *queriesCache
	)

	cache = NewQueriesCache().(*queriesCache)

	d = directory.New()
	d.AddService("configProvider", suite.ConfigProvider)
	d.AddService("queriesCache", cache)

	if err := d.Start(); err != nil {
		suite.log.Fatalf("Could not start directory: %v", err)
	}

	suite.cache = cache
	suite.cache.collection.Remove(map[string]string{})
}
示例#5
0
func (suite *QueryTestSuite) SetupTest() {
	suite.log = logger.Log("queries_test")

	var (
		d              directory.Directory
		systemQueries  MockSystemQueries
		gameCalculator MockGameCalculator
		events         MockEventsService
		queriesCache   MockQueriesCache
	)

	d = directory.New()
	suite.InitTestConfig()
	d.AddService("configProvider", suite.ConfigProvider)
	d.AddService("systemQueries", &systemQueries)
	d.AddService("gameCalculator", &gameCalculator)
	d.AddService("eventsService", &events)
	d.AddService("queriesCache", &queriesCache)

	if err := d.Start(); err != nil {
		suite.log.Fatalf("Could not start directory: %v", err)
	}

	suite.mockSystemQueries = &systemQueries
	suite.mockGameCalculator = &gameCalculator
	suite.mockEvents = &events
	suite.mockQueriesCache = &queriesCache
}