(t *testing.T)
| 373 | } |
| 374 | |
| 375 | func TestOpenTopicFromURL(t *testing.T) { |
| 376 | cleanup := setup.FakeGCPDefaultCredentials(t) |
| 377 | defer cleanup() |
| 378 | |
| 379 | tests := []struct { |
| 380 | URL string |
| 381 | WantErr bool |
| 382 | }{ |
| 383 | // OK, short form. |
| 384 | {"gcppubsub://myproject/mytopic", false}, |
| 385 | // OK, long form. |
| 386 | {"gcppubsub://projects/myproject/topic/mytopic", false}, |
| 387 | // Invalid parameter. |
| 388 | {"gcppubsub://myproject/mytopic?param=value", true}, |
| 389 | // Valid max_send_batch_size |
| 390 | {"gcppubsub://projects/mytopic?max_send_batch_size=1", false}, |
| 391 | // Invalid max_send_batch_size |
| 392 | {"gcppubsub://projects/mytopic?max_send_batch_size=0", true}, |
| 393 | // Invalid max_send_batch_size |
| 394 | {"gcppubsub://projects/mytopic?max_send_batch_size=1001", true}, |
| 395 | } |
| 396 | |
| 397 | ctx := context.Background() |
| 398 | for _, test := range tests { |
| 399 | topic, err := pubsub.OpenTopic(ctx, test.URL) |
| 400 | if (err != nil) != test.WantErr { |
| 401 | t.Errorf("%s: got error %v, want error %v", test.URL, err, test.WantErr) |
| 402 | } |
| 403 | if topic != nil { |
| 404 | topic.Shutdown(ctx) |
| 405 | } |
| 406 | } |
| 407 | } |
| 408 | |
| 409 | func TestOpenSubscriptionFromURL(t *testing.T) { |
| 410 | cleanup := setup.FakeGCPDefaultCredentials(t) |
nothing calls this directly
no test coverage detected