Add Lua plugin host, built-in amazon plugin and dibs check.

Sandboxed gopher-lua with time, memory and call-stack limits from
[sandbox], a goquery-backed doc API, price parsing, and the 'check',
'plugin test' and 'fixtures' commands. Sellers are first_party,
fulfilled (shipped by the shop) or third_party, and items accept
fulfilled by default; used-only offers are not available. Plugin tests
run on real pages that 'dibs fixtures' fetches into an untracked
directory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
OverlordandClaude Bot committed 2026-10-14 01:46:03 +02:00
1 parent f90ef18f90
commit bb010356a0
28 files changed
+2096 -26

No files matched your search

+22 -5
View File
@@ -21,9 +21,10 @@ seller = "any"
interval = "5m"
[[item]]
name = "Console"
shop = "mediamarkt"
urls = ["https://www.mediamarkt.de/de/product/_console-123.html"]
name = "Console"
shop = "mediamarkt"
seller = "fulfilled"
urls = ["https://www.mediamarkt.de/de/product/_console-123.html"]
[accounts.amazon]
username = "me@example.com"
@@ -104,6 +105,8 @@ func TestLoadFull(t *testing.T) {
if len(cfg.Items) != 2 {
t.Fatalf("items: got %d, want 2", len(cfg.Items))
}
if s := cfg.Items[1].Seller; s != SellerFulfilled { t.Errorf("item[1].seller: got %q, want fulfilled", s) }
it := cfg.Items[0]
if it.Currency != "EUR" {
t.Errorf("currency: got %q, want it uppercased to EUR", it.Currency)
@@ -145,7 +148,7 @@ urls = ["https://www.amazon.de/dp/B0HMX2FSTF"]
t.Fatal(err)
}
it := cfg.Items[0]
if it.Seller != SellerFirstParty || it.Interval.Duration != DefaultInterval || it.MaxPrice != nil {
if it.Seller != SellerFulfilled || it.Interval.Duration != DefaultInterval || it.MaxPrice != nil {
t.Errorf("item defaults: got %+v", it)
}
if cfg.Accounts["amazon"].CartMode != CartModeDeeplink {
@@ -273,7 +276,7 @@ call_stack = 1
wantErr(t, es, "item[0].urls[0]", 4, "http:// or https://")
wantErr(t, es, "item[0].max_price", 5, "positive")
wantErr(t, es, "item[0].currency", 6, "ISO 4217")
wantErr(t, es, "item[0].seller", 7, `"first_party" or "any"`)
wantErr(t, es, "item[0].seller", 7, `"first_party", "fulfilled" or "any"`)
wantErr(t, es, "item[0].interval", 8, "at least 1m0s")
wantErr(t, es, "item[1].urls[0]", 13, "duplicate URL (also item[0].urls[1])")
wantErr(t, es, "item[1].fx_margin", 14, "needs both currency and max_price")
@@ -334,3 +337,17 @@ func TestErrorFormat(t *testing.T) {
t.Errorf("got %q, want %q", got, want)
}
}
func TestAcceptsSeller(t *testing.T) {
for policy, want := range map[string]map[string]bool{
SellerFirstParty: {"first_party": true, "fulfilled": false, "third_party": false, "unknown": false},
SellerFulfilled: {"first_party": true, "fulfilled": true, "third_party": false, "unknown": false},
SellerAny: {"first_party": true, "fulfilled": true, "third_party": true, "unknown": true},
} {
for seller, ok := range want {
if got := (Item{Seller: policy}).AcceptsSeller(seller); got != ok { t.Errorf("policy %s, seller %s: got %v, want %v", policy, seller, got, ok) }
}
if (Item{Seller: policy}).AcceptsSeller("amazon") { t.Errorf("policy %s accepts an invalid seller", policy) }
}
}