updated hws.ThrowError to not return an error and log it to console instead

fixed errors_test

fixed tests
This commit is contained in:
2026-02-03 18:11:17 +11:00
parent 95a17597cf
commit 563908bbb4
14 changed files with 249 additions and 239 deletions

View File

@@ -169,7 +169,7 @@ func Test_LogFatal(t *testing.T) {
// Note: We cannot actually test Fatal() as it calls os.Exit()
// Testing this would require subprocess testing which is overly complex
// These tests document the expected behavior and verify the function signatures exist
t.Run("LogFatal with nil logger prints to stdout", func(t *testing.T) {
_, err := hws.NewServer(&hws.Config{
Host: "127.0.0.1",
@@ -197,7 +197,7 @@ func Test_LoggerIgnorePaths(t *testing.T) {
err := server.LoggerIgnorePaths("http://example.com/path")
assert.Error(t, err)
assert.Contains(t, err.Error(), "Invalid path")
assert.Contains(t, err.Error(), "invalid path")
})
t.Run("Invalid path with host", func(t *testing.T) {
@@ -207,7 +207,7 @@ func Test_LoggerIgnorePaths(t *testing.T) {
err := server.LoggerIgnorePaths("//example.com/path")
assert.Error(t, err)
if err != nil {
assert.Contains(t, err.Error(), "Invalid path")
assert.Contains(t, err.Error(), "invalid path")
}
})
@@ -217,7 +217,7 @@ func Test_LoggerIgnorePaths(t *testing.T) {
err := server.LoggerIgnorePaths("/path?query=value")
assert.Error(t, err)
assert.Contains(t, err.Error(), "Invalid path")
assert.Contains(t, err.Error(), "invalid path")
})
t.Run("Invalid path with fragment", func(t *testing.T) {
@@ -226,7 +226,7 @@ func Test_LoggerIgnorePaths(t *testing.T) {
err := server.LoggerIgnorePaths("/path#fragment")
assert.Error(t, err)
assert.Contains(t, err.Error(), "Invalid path")
assert.Contains(t, err.Error(), "invalid path")
})
t.Run("Valid paths", func(t *testing.T) {