From e7a906debf4a0f9293c252688721b7b31632e471 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 20 Sep 2026 00:32:42 +0200 Subject: [PATCH] Expect the nine core methods, and a Go bool reading safe and idempotent --- data_test.go | 6 +++--- table_test.go | 21 ++++++++++++++++----- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/data_test.go b/data_test.go index a67110a..a0d465f 100644 --- a/data_test.go +++ b/data_test.go @@ -111,9 +111,9 @@ func TestShippedMiscReferenceData(t *testing.T) { "timezone.weight": regexp.MustCompile(`^[1-9]\d*$`), "mimetype": regexp.MustCompile(`^[a-z]+/[a-z0-9.+-]+$`), "mimetype.ext": regexp.MustCompile(`^\.[a-z0-9_-]+$`), - "httpmethod": regexp.MustCompile(`^[A-Za-z][A-Za-z-]*$`), - "httpmethod.safe": regexp.MustCompile(`^(yes|no)$`), - "httpmethod.idempotent": regexp.MustCompile(`^(yes|no)$`), + "httpmethod": regexp.MustCompile(`^(CONNECT|DELETE|GET|HEAD|OPTIONS|PATCH|POST|PUT|TRACE)$`), + "httpmethod.safe": regexp.MustCompile(`^(true|false)$`), + "httpmethod.idempotent": regexp.MustCompile(`^(true|false)$`), "port": regexp.MustCompile(`^[1-9]\d{0,4}$`), "port.service": regexp.MustCompile(`^\S+$`), "protocol": regexp.MustCompile(`^\S+( \S+)*$`), diff --git a/table_test.go b/table_test.go index e7464eb..db817f6 100644 --- a/table_test.go +++ b/table_test.go @@ -701,11 +701,11 @@ func TestShippedTables(t *testing.T) { "timezone[Asia/Kathmandu].offset": "+05:45", "timezone[America/New_York].offset": "-05:00", "territory[SE].timezone": "Europe/Stockholm", - "httpmethod[GET].safe": "yes", - "httpmethod[GET].idempotent": "yes", - "httpmethod[POST].safe": "no", - "httpmethod[POST].idempotent": "no", - "httpmethod[PUT].idempotent": "yes", + "httpmethod[GET].safe": "true", + "httpmethod[GET].idempotent": "true", + "httpmethod[POST].safe": "false", + "httpmethod[POST].idempotent": "false", + "httpmethod[PUT].idempotent": "true", "protocol[TCP].number": "6", "protocol[UDP].number": "17", "protocol[ICMP].name": "Internet Control Message", @@ -754,6 +754,17 @@ func TestShippedTables(t *testing.T) { t.Fatalf("%q: a territory and a timezone in one render disagree on the territory", got) } } + var row struct { + Idempotent bool `fake:"misc.httpmethod.idempotent"` + Method string `fake:"misc.httpmethod.method"` + Safe bool `fake:"misc.httpmethod.safe"` + } + if err := newGenerator(t, "data", WithSeed(1)).FakeStruct(&row); err != nil { + t.Fatalf("FakeStruct into a bool = %v, want the register's yes and no shipped as true and false", err) + } + if row.Method == "GET" && !(row.Safe && row.Idempotent) { + t.Fatalf("GET drew safe=%v idempotent=%v", row.Safe, row.Idempotent) + } zones := map[string]int{} for i := 0; i < 2000; i++ { zones[fake(t, f, "territory[US].timezone")]++