Ejemplo n.º 1
0
func TestInitSettings(t *testing.T) {
	s := helpers.Settings{}
	for _, test := range initSettingsTests {
		ret := s.InitSettings(test.envVars)
		if (ret == nil) != test.returnValueNull {
			t.Errorf("Test %s did not return correct value. Expected %t, Actual %t", test.testName, test.returnValueNull, (ret == nil))
		}
	}
}
Ejemplo n.º 2
0
// InitApp takes in envars and sets up the router and settings that will be used for the unstarted server.
func InitApp(envVars helpers.EnvVars) (*web.Router, *helpers.Settings, error) {
	// Initialize the settings.
	settings := helpers.Settings{}
	if err := settings.InitSettings(envVars); err != nil {
		return nil, nil, err
	}

	// Cache templates
	templates := template.Must(template.ParseFiles(filepath.Join(envVars.BasePath, "static", "index.html")))

	// Initialize the router
	router := InitRouter(&settings, templates)

	return router, &settings, nil
}
Ejemplo n.º 3
0
// CreateRouterWithMockSession will create a settings with the appropriate envVars and load the mock session with the session data.
func CreateRouterWithMockSession(sessionData map[string]interface{}, envVars helpers.EnvVars) (*web.Router, *MockSessionStore) {
	// Initialize settings.
	settings := helpers.Settings{}
	settings.InitSettings(envVars)

	// Initialize a new session store.
	store := MockSessionStore{}
	store.ResetSessionData(sessionData, "")

	// Override the session store.
	settings.Sessions = store

	// Create the router.
	router := controllers.InitRouter(&settings, &template.Template{})

	return router, &store
}