(t *testing.T)
| 100 | } |
| 101 | |
| 102 | func TestOpenSubscriptionFromURL(t *testing.T) { |
| 103 | tests := []struct { |
| 104 | URL string |
| 105 | WantErr bool |
| 106 | }{ |
| 107 | // OK. |
| 108 | {"mem://mytopic", false}, |
| 109 | // OK with ackdeadline |
| 110 | {"mem://mytopic?ackdeadline=30s", false}, |
| 111 | // Invalid ackdeadline |
| 112 | {"mem://mytopic?ackdeadline=notaduration", true}, |
| 113 | // Nonexistent topic. |
| 114 | {"mem://nonexistenttopic", true}, |
| 115 | // Invalid parameter. |
| 116 | {"mem://myproject/mysub?param=value", true}, |
| 117 | } |
| 118 | |
| 119 | ctx := context.Background() |
| 120 | pubsub.OpenTopic(ctx, "mem://mytopic") |
| 121 | for _, test := range tests { |
| 122 | sub, err := pubsub.OpenSubscription(ctx, test.URL) |
| 123 | if (err != nil) != test.WantErr { |
| 124 | t.Errorf("%s: got error %v, want error %v", test.URL, err, test.WantErr) |
| 125 | } |
| 126 | if sub != nil { |
| 127 | sub.Shutdown(ctx) |
| 128 | } |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | func TestSendNoSubs(t *testing.T) { |
| 133 | // It's OK to send a message to a topic with no subscribers. |
nothing calls this directly
no test coverage detected