fix: log watch-order parse fallback

This commit is contained in:
2026-04-11 22:16:32 +02:00
parent 197c9c7485
commit f38ab058e0
3 changed files with 35 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ package watchorder
import (
"context"
"errors"
"net/http"
"net/http/httptest"
"testing"
@@ -52,6 +53,16 @@ func testHTMLEmptyRows() string {
</html>`
}
func testHTMLWithoutWatchOrderTable() string {
return `
<!doctype html>
<html>
<body>
<p>challenge page</p>
</body>
</html>`
}
func TestFetchWatchOrder_OutputShape(t *testing.T) {
server := testServer(testHTMLWithMetadata())
defer server.Close()
@@ -103,3 +114,14 @@ func TestFetchWatchOrder_NoRowsReturnsEmpty(t *testing.T) {
t.Fatalf("expected no entries, got %d", len(result.WatchOrder))
}
}
func TestFetchWatchOrder_MissingMarkupReturnsError(t *testing.T) {
server := testServer(testHTMLWithoutWatchOrderTable())
defer server.Close()
url := server.URL + "/?/tools/watch_order/id/1535"
_, err := FetchWatchOrder(context.Background(), &http.Client{Timeout: time.Second}, url)
if !errors.Is(err, ErrWatchOrderMarkupNotFound) {
t.Fatalf("expected ErrWatchOrderMarkupNotFound, got %v", err)
}
}