fix: log watch-order parse fallback
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user