- Extract shared DeferClose helper, removing 14 duplicate copies - Rename PlayWright-prefixed types to cleaner names (BrowserOptions, BrowserSelection, NewBrowser, etc.) - Rename fields: ServerAddress, RequireServer (was DontLaunchOnConnectFailure) - Extract shared initBrowser/mergeOptions into browser_init.go, deduplicating ~120 lines between NewBrowser and NewInteractiveBrowser - Remove unused locator field from document struct - Add tests for all previously untested packages (archive, aislegopher, wegmans, useragents, powerball) and expand existing test suites - Add MIGRATION.md documenting all breaking API changes Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
package wegmans
|
|
|
|
import (
|
|
"context"
|
|
"net/url"
|
|
"testing"
|
|
)
|
|
|
|
func TestGetItemPrice_NilBrowser(t *testing.T) {
|
|
u, _ := url.Parse("https://shop.wegmans.com/product/24921")
|
|
_, err := DefaultConfig.GetItemPrice(context.Background(), nil, u)
|
|
if err != ErrNilBrowser {
|
|
t.Errorf("expected ErrNilBrowser, got %v", err)
|
|
}
|
|
}
|
|
|
|
func TestGetItemPrice_NilURL(t *testing.T) {
|
|
// NilBrowser check comes before NilURL, so we can't test NilURL
|
|
// independently without a real browser. Verify the error sentinel exists.
|
|
if ErrNilURL.Error() != "url is nil" {
|
|
t.Errorf("ErrNilURL = %q, want %q", ErrNilURL.Error(), "url is nil")
|
|
}
|
|
}
|
|
|
|
func TestGetItemPrice_ErrorSentinels(t *testing.T) {
|
|
if ErrInvalidURL.Error() != "invalid url" {
|
|
t.Errorf("ErrInvalidURL = %q, want %q", ErrInvalidURL.Error(), "invalid url")
|
|
}
|
|
if ErrNilBrowser.Error() != "browser is nil" {
|
|
t.Errorf("ErrNilBrowser = %q, want %q", ErrNilBrowser.Error(), "browser is nil")
|
|
}
|
|
}
|
|
|
|
func TestItem_ZeroValue(t *testing.T) {
|
|
var item Item
|
|
if item.ID != 0 || item.Name != "" || item.Price != 0 || item.UnitPrice != 0 || item.Unit != "" {
|
|
t.Error("zero-value Item should have empty/zero fields")
|
|
}
|
|
}
|