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

Function TestKV_keyValid

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

Source from the content-addressed store, hash-verified

528}
529
530func TestKV_keyValid(t *testing.T) {
531 tests := []struct {
532 key string
533 ok bool
534 }{
535 {key: "foo123", ok: true},
536 {key: "foo.bar", ok: true},
537 {key: "Foo.123=bar_baz-abc", ok: true},
538 {key: "foo.*.bar", ok: false},
539 {key: "foo.>", ok: false},
540 {key: ">", ok: false},
541 {key: "*", ok: false},
542 {key: "foo!", ok: false},
543 {key: "foo bar", ok: false},
544 {key: "", ok: false},
545 {key: " ", ok: false},
546 {key: ".", ok: false},
547 {key: ".foo", ok: false},
548 {key: "foo.", ok: false},
549 }
550
551 for _, test := range tests {
552 t.Run(test.key, func(t *testing.T) {
553 res := keyValid(test.key)
554 if res != test.ok {
555 t.Fatalf("Invalid result; want: %v; got: %v", test.ok, res)
556 }
557 })
558 }
559}
560
561func TestKV_searchKeyValid(t *testing.T) {
562 tests := []struct {

Callers

nothing calls this directly

Calls 2

FatalfMethod · 0.80
keyValidFunction · 0.70

Tested by

no test coverage detected