Add end-to-end smoke driving the real CLI against the containerized fake

This commit is contained in:
2026-08-29 06:58:35 -05:00
parent d98f0aeb93
commit bbd85fae71
4 changed files with 211 additions and 12 deletions
+25 -12
View File
@@ -126,14 +126,32 @@ type Status struct {
// New starts a fake on a random port with Redmine's default
// enumerations and an empty MOPAC project.
func New(apiKey string) *Server {
s := &Server{
APIKey: apiKey,
apiKeySet: true,
issues: map[int]*Issue{},
versions: map[int]Version{},
s := newServer(apiKey)
mux := http.NewServeMux()
mux.HandleFunc("/", s.handler)
s.srv = httptest.NewServer(mux)
s.URL = s.srv.URL
return s
}
// ListenAndServe runs the fake on a fixed address (the smoke run boots it
// in a container). An empty apiKey disables auth checking.
func ListenAndServe(addr, apiKey string) error {
s := newServer(apiKey)
mux := http.NewServeMux()
mux.HandleFunc("/", s.handler)
return http.ListenAndServe(addr, mux)
}
func newServer(apiKey string) *Server {
return &Server{
APIKey: apiKey,
apiKeySet: true,
issues: map[int]*Issue{},
versions: map[int]Version{},
categories: map[int]Category{},
relations: map[int]Relation{},
nextID: 100,
relations: map[int]Relation{},
nextID: 100,
Trackers: []IDName{
{1, "Bug"}, {2, "Feature"}, {3, "Support"}, {4, "Task"},
},
@@ -145,11 +163,6 @@ func New(apiKey string) *Server {
{1, "Low"}, {2, "Normal"}, {3, "High"}, {4, "Urgent"}, {5, "Immediate"},
},
}
mux := http.NewServeMux()
mux.HandleFunc("/", s.handler)
s.srv = httptest.NewServer(mux)
s.URL = s.srv.URL
return s
}
// Close shuts the fake down.