MCPcopy
hub / github.com/nats-io/nats.go / TestKV_bucketValid

Function TestKV_bucketValid

jetstream/jetstream_test.go:592–621  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

590}
591
592func TestKV_bucketValid(t *testing.T) {
593 tests := []struct {
594 key string
595 ok bool
596 }{
597 {key: "foo123", ok: true},
598 {key: "Foo123-bar_baz", ok: true},
599 {key: "foo.bar", ok: false},
600 {key: "foo.*.bar", ok: false},
601 {key: "foo.>", ok: false},
602 {key: ">", ok: false},
603 {key: "*", ok: false},
604 {key: "foo!", ok: false},
605 {key: "foo bar", ok: false},
606 {key: "", ok: false},
607 {key: " ", ok: false},
608 {key: ".", ok: false},
609 {key: ".foo", ok: false},
610 {key: "foo.", ok: false},
611 }
612
613 for _, test := range tests {
614 t.Run(test.key, func(t *testing.T) {
615 res := bucketValid(test.key)
616 if res != test.ok {
617 t.Fatalf("Invalid result; want: %v; got: %v", test.ok, res)
618 }
619 })
620 }
621}

Callers

nothing calls this directly

Calls 2

FatalfMethod · 0.80
bucketValidFunction · 0.70

Tested by

no test coverage detected