mirror of
https://github.com/pikami/cosmium.git
synced 2025-12-20 01:10:44 +00:00
Refactor to support multiple server instances in shared library
This commit is contained in:
@@ -5,14 +5,37 @@ import (
|
||||
|
||||
"github.com/pikami/cosmium/api"
|
||||
"github.com/pikami/cosmium/api/config"
|
||||
"github.com/pikami/cosmium/internal/repositories"
|
||||
)
|
||||
|
||||
func runTestServer() *httptest.Server {
|
||||
config.Config.AccountKey = config.DefaultAccountKey
|
||||
config.Config.ExplorerPath = "/tmp/nothing"
|
||||
config.Config.ExplorerBaseUrlLocation = config.ExplorerBaseUrlLocation
|
||||
type TestServer struct {
|
||||
Server *httptest.Server
|
||||
Repository *repositories.DataRepository
|
||||
URL string
|
||||
}
|
||||
|
||||
return httptest.NewServer(api.CreateRouter())
|
||||
func runTestServerCustomConfig(config config.ServerConfig) *TestServer {
|
||||
repository := repositories.NewDataRepository(repositories.RepositoryOptions{})
|
||||
|
||||
api := api.NewApiServer(repository, config)
|
||||
|
||||
server := httptest.NewServer(api.GetRouter())
|
||||
|
||||
return &TestServer{
|
||||
Server: server,
|
||||
Repository: repository,
|
||||
URL: server.URL,
|
||||
}
|
||||
}
|
||||
|
||||
func runTestServer() *TestServer {
|
||||
config := config.ServerConfig{
|
||||
AccountKey: config.DefaultAccountKey,
|
||||
ExplorerPath: "/tmp/nothing",
|
||||
ExplorerBaseUrlLocation: config.ExplorerBaseUrlLocation,
|
||||
}
|
||||
|
||||
return runTestServerCustomConfig(config)
|
||||
}
|
||||
|
||||
const (
|
||||
|
||||
Reference in New Issue
Block a user