|
|
@ -462,7 +462,7 @@ func Test_MultiAppSubSubApp(t *testing.T) { |
|
|
|
subapp.Bind(&MultiAppController{ |
|
|
|
test: "subapp", |
|
|
|
BaseController: capstan.BaseController{ |
|
|
|
Index: "/", |
|
|
|
Path: "/", |
|
|
|
}, |
|
|
|
}) |
|
|
|
|
|
|
@ -574,3 +574,102 @@ func Test_MultiAppSubSubApp(t *testing.T) { |
|
|
|
t.Errorf("expected `index: subsubapp`; got %s", string(out)) |
|
|
|
} |
|
|
|
} |
|
|
|
func Test_MultiAppSubSubAppDestroy(t *testing.T) { |
|
|
|
server := NewServer(func(app capstan.Application) { |
|
|
|
app.Bind(&MultiAppController{ |
|
|
|
test: "app", |
|
|
|
BaseController: capstan.BaseController{ |
|
|
|
Path: "/main", |
|
|
|
}, |
|
|
|
}) |
|
|
|
app.Config().Server.Hostname = "example.com" |
|
|
|
|
|
|
|
subapp := capstan.New(&config.Config{ |
|
|
|
Server: &config.ServerConfig{ |
|
|
|
Hostname: "subapp.example.com", |
|
|
|
}, |
|
|
|
}) |
|
|
|
|
|
|
|
subapp.Bind(&MultiAppController{ |
|
|
|
test: "subapp", |
|
|
|
BaseController: capstan.BaseController{ |
|
|
|
Path: "/", |
|
|
|
}, |
|
|
|
}) |
|
|
|
|
|
|
|
subapp.Bind(&MultiAppController{ |
|
|
|
test: "subapp", |
|
|
|
BaseController: capstan.BaseController{ |
|
|
|
Path: "/app", |
|
|
|
}, |
|
|
|
}) |
|
|
|
app.AttachApplication(subapp) |
|
|
|
|
|
|
|
subsubapp := capstan.New(&config.Config{ |
|
|
|
Server: &config.ServerConfig{ |
|
|
|
Hostname: "sub.subapp.example.com", |
|
|
|
}, |
|
|
|
}) |
|
|
|
|
|
|
|
subsubapp.Bind(&MultiAppController{ |
|
|
|
test: "subsubapp", |
|
|
|
BaseController: capstan.BaseController{ |
|
|
|
Path: "/subsubapp", |
|
|
|
}, |
|
|
|
}) |
|
|
|
subapp.AttachApplication(subsubapp) |
|
|
|
|
|
|
|
subapp.DestroyApplication(subsubapp) |
|
|
|
app.DestroyApplication(subapp) |
|
|
|
|
|
|
|
}) |
|
|
|
defer server.Close() |
|
|
|
|
|
|
|
requester := please.MakeRequest(server.URL) |
|
|
|
requester.SetClient(server.Client()) |
|
|
|
|
|
|
|
req := requester.Get("/main") |
|
|
|
req.Host = "example.com" |
|
|
|
response, err := req.Commit() |
|
|
|
if err != nil { |
|
|
|
t.Fatalf("/main: response error during request: %v", errors.Unfurl(err)) |
|
|
|
} |
|
|
|
|
|
|
|
if response.StatusCode != 200 { |
|
|
|
t.Errorf("response received non-200 status code: %d", response.StatusCode) |
|
|
|
} |
|
|
|
|
|
|
|
req = requester.Get("/") |
|
|
|
req.Host = "subapp.example.com" |
|
|
|
response, err = req.Commit() |
|
|
|
if err != nil { |
|
|
|
t.Fatalf("/main: response error during request: %v", errors.Unfurl(err)) |
|
|
|
} |
|
|
|
|
|
|
|
if response.StatusCode != 404 { |
|
|
|
t.Errorf("response received non-404 status code: %d", response.StatusCode) |
|
|
|
} |
|
|
|
|
|
|
|
req = requester.Get("/app") |
|
|
|
req.Host = "subapp.example.com" |
|
|
|
response, err = req.Commit() |
|
|
|
if err != nil { |
|
|
|
t.Fatalf("/main: response error during request: %v", errors.Unfurl(err)) |
|
|
|
} |
|
|
|
|
|
|
|
if response.StatusCode != 404 { |
|
|
|
t.Errorf("response received non-404 status code: %d", response.StatusCode) |
|
|
|
} |
|
|
|
|
|
|
|
req = requester.Get("/subsubapp") |
|
|
|
req.Host = "sub.subapp.example.com" |
|
|
|
response, err = req.Commit() |
|
|
|
if err != nil { |
|
|
|
t.Fatalf("/subsubapp: response error during request: %v", errors.Unfurl(err)) |
|
|
|
} |
|
|
|
|
|
|
|
if response.StatusCode != 404 { |
|
|
|
t.Errorf("response received non-404 status code: %d", response.StatusCode) |
|
|
|
} |
|
|
|
|
|
|
|
} |