| 77 | } |
| 78 | |
| 79 | func TestOpenTopicFromURL(t *testing.T) { |
| 80 | tests := []struct { |
| 81 | URL string |
| 82 | WantErr bool |
| 83 | }{ |
| 84 | // OK. |
| 85 | {"mem://mytopic", false}, |
| 86 | // Invalid parameter. |
| 87 | {"mem://mytopic?param=value", true}, |
| 88 | } |
| 89 | |
| 90 | ctx := context.Background() |
| 91 | for _, test := range tests { |
| 92 | topic, err := pubsub.OpenTopic(ctx, test.URL) |
| 93 | if (err != nil) != test.WantErr { |
| 94 | t.Errorf("%s: got error %v, want error %v", test.URL, err, test.WantErr) |
| 95 | } |
| 96 | if topic != nil { |
| 97 | topic.Shutdown(ctx) |
| 98 | } |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | func TestOpenSubscriptionFromURL(t *testing.T) { |
| 103 | tests := []struct { |