mirror of
https://github.com/caddyserver/caddy.git
synced 2025-04-02 03:21:50 +02:00
noot
This commit is contained in:
parent
2619271a5c
commit
b98c89fbb6
1 changed files with 8 additions and 2 deletions
|
@ -10,12 +10,18 @@ import (
|
||||||
|
|
||||||
"github.com/aryann/difflib"
|
"github.com/aryann/difflib"
|
||||||
"github.com/caddyserver/caddy/v2/caddyconfig"
|
"github.com/caddyserver/caddy/v2/caddyconfig"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AssertLoadError will load a config and expect an error
|
// AssertLoadError will load a config and expect an error
|
||||||
func AssertLoadError(t *testing.T, rawConfig string, configType string, expectedError string) {
|
func AssertLoadError(t *testing.T, rawConfig string, configType string, expectedError string) {
|
||||||
tc := StartHarness(t)
|
tc, err := NewTester()
|
||||||
err := tc.tester.LoadConfig(rawConfig, configType)
|
require.NoError(t, err)
|
||||||
|
err = tc.LaunchCaddy()
|
||||||
|
require.NoError(t, err)
|
||||||
|
defer tc.CleanupCaddy()
|
||||||
|
|
||||||
|
err = tc.LoadConfig(rawConfig, configType)
|
||||||
if !strings.Contains(err.Error(), expectedError) {
|
if !strings.Contains(err.Error(), expectedError) {
|
||||||
t.Errorf("expected error \"%s\" but got \"%s\"", expectedError, err.Error())
|
t.Errorf("expected error \"%s\" but got \"%s\"", expectedError, err.Error())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue