Expect the nine core methods, and a Go bool reading safe and idempotent
This commit is contained in:
+3
-3
@@ -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+)*$`),
|
||||
|
||||
+16
-5
@@ -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")]++
|
||||
|
||||
Reference in New Issue
Block a user