Skip to content

gitserver: able to mock out frontend for loading configuration using env var

Created by: unknwon

Currently, the gitserver depends on loading initial configuration from frontend to be able to start. This is not ideal for integration testing of gitserver (i.e. boot up the gitserver Docker image alone).

We should be able to mock out configuration using an environment variable for testing purpose.

The following code might work:

mockConfig := os.Getenv("SRC_MOCK_CONFIG")
if mockConfig != "" {
	// Read the file and parse it
	cfg := readAndParseConfig(mockConfig)
	conf.Mock(cfg) // This is enough to unblock conf.Get calls
}