test(smoke): end-to-end smoke driving the real CLI against the containerized fake
This commit is contained in:
@@ -133,20 +133,29 @@ type FailSpec struct {
|
||||
// New starts a fake on a random port authenticating as login.
|
||||
func New(token, login string) *Server {
|
||||
s := newServer(token, login)
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/", s.handler)
|
||||
s.srv = httptest.NewServer(mux)
|
||||
s.srv = httptest.NewServer(s.Handler())
|
||||
s.URL = s.srv.URL
|
||||
return s
|
||||
}
|
||||
|
||||
// NewState builds an unstarted fake: seed it with the Add* methods, then
|
||||
// serve Handler() however the process needs (the smoke run does).
|
||||
func NewState(token, login string) *Server {
|
||||
return newServer(token, login)
|
||||
}
|
||||
|
||||
// Handler returns the fake's HTTP handler.
|
||||
func (s *Server) Handler() http.Handler {
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/", s.handler)
|
||||
return mux
|
||||
}
|
||||
|
||||
// ListenAndServe runs the fake on a fixed address (the smoke run boots it
|
||||
// in a container). An empty token disables auth checking.
|
||||
func ListenAndServe(addr, token string) error {
|
||||
s := newServer(token, "ukrrs")
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/", s.handler)
|
||||
return http.ListenAndServe(addr, mux)
|
||||
return http.ListenAndServe(addr, s.Handler())
|
||||
}
|
||||
|
||||
func newServer(token, login string) *Server {
|
||||
|
||||
Reference in New Issue
Block a user