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

Function TestStreamInfoSubjectInfo

test/js_test.go:3735–3772  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3733}
3734
3735func TestStreamInfoSubjectInfo(t *testing.T) {
3736 s := RunBasicJetStreamServer()
3737 defer shutdownJSServerAndRemoveStorage(t, s)
3738
3739 nc, js := jsClient(t, s)
3740 defer nc.Close()
3741
3742 _, err := js.AddStream(&nats.StreamConfig{
3743 Name: "foo",
3744 Subjects: []string{"foo.*"},
3745 })
3746 if err != nil {
3747 t.Fatalf("Unexpected error: %v", err)
3748 }
3749
3750 if _, err := js.Publish("foo.A", []byte("")); err != nil {
3751 t.Fatalf("Unexpected error during publish: %v", err)
3752 }
3753 if _, err := js.Publish("foo.B", []byte("")); err != nil {
3754 t.Fatalf("Unexpected error during publish: %v", err)
3755 }
3756
3757 si, err := js.StreamInfo("foo", &nats.StreamInfoRequest{
3758 SubjectsFilter: "foo.A",
3759 })
3760 if err != nil {
3761 t.Fatalf("Unexpected error: %v", err)
3762 }
3763 if si.State.NumSubjects != 2 {
3764 t.Fatal("Expected NumSubjects to be 1")
3765 }
3766 if len(si.State.Subjects) != 1 {
3767 t.Fatal("Expected Subjects len to be 1")
3768 }
3769 if si.State.Subjects["foo.A"] != 1 {
3770 t.Fatal("Expected Subjects to have an entry for foo.A with a count of 1")
3771 }
3772}
3773
3774func TestStreamInfoDeletedDetails(t *testing.T) {
3775 testData := []string{"one", "two", "three", "four"}

Callers

nothing calls this directly

Calls 8

FatalfMethod · 0.80
RunBasicJetStreamServerFunction · 0.70
jsClientFunction · 0.70
AddStreamMethod · 0.65
PublishMethod · 0.65
StreamInfoMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected