(t *testing.T)
| 59 | } |
| 60 | |
| 61 | func TestSubscriptions(t *testing.T) { |
| 62 | c := subscriptions.NewDefaultClient() |
| 63 | |
| 64 | if len(c.Subscriptions()) != 0 { |
| 65 | t.Fatalf("Expected subscriptions to be empty") |
| 66 | } |
| 67 | |
| 68 | c.Subscribe("sub1", "sub11", "sub2") |
| 69 | |
| 70 | scenarios := []struct { |
| 71 | prefixes []string |
| 72 | expected []string |
| 73 | }{ |
| 74 | {nil, []string{"sub1", "sub11", "sub2"}}, |
| 75 | {[]string{"missing"}, nil}, |
| 76 | {[]string{"sub1"}, []string{"sub1", "sub11"}}, |
| 77 | {[]string{"sub2"}, []string{"sub2"}}, // with extra query start char |
| 78 | } |
| 79 | |
| 80 | for _, s := range scenarios { |
| 81 | t.Run(strings.Join(s.prefixes, ","), func(t *testing.T) { |
| 82 | subs := c.Subscriptions(s.prefixes...) |
| 83 | |
| 84 | if len(subs) != len(s.expected) { |
| 85 | t.Fatalf("Expected %d subscriptions, got %d", len(s.expected), len(subs)) |
| 86 | } |
| 87 | |
| 88 | for _, s := range s.expected { |
| 89 | if _, ok := subs[s]; !ok { |
| 90 | t.Fatalf("Missing subscription %q in \n%v", s, subs) |
| 91 | } |
| 92 | } |
| 93 | }) |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | func TestSubscribe(t *testing.T) { |
| 98 | c := subscriptions.NewDefaultClient() |
nothing calls this directly
no test coverage detected
searching dependent graphs…