MCPcopy
hub / github.com/caddyserver/caddy / AssertLoadError

Function AssertLoadError

caddytest/caddytest.go:364–373  ·  view source on GitHub ↗

AssertLoadError will load a config and expect an error

(t *testing.T, rawConfig string, configType string, expectedError string)

Source from the content-addressed store, hash-verified

362
363// AssertLoadError will load a config and expect an error
364func AssertLoadError(t *testing.T, rawConfig string, configType string, expectedError string) {
365 t.Helper()
366
367 tc := NewTester(t)
368
369 err := tc.initServer(rawConfig, configType)
370 if !strings.Contains(err.Error(), expectedError) {
371 t.Errorf("expected error \"%s\" but got \"%s\"", expectedError, err.Error())
372 }
373}
374
375// AssertRedirect makes a request and asserts the redirection happens
376func (tc *Tester) AssertRedirect(requestURI string, expectedToLocation string, expectedStatusCode int) *http.Response {

Calls 3

initServerMethod · 0.95
NewTesterFunction · 0.85
ErrorMethod · 0.45