(t *testing.T)
| 407 | } |
| 408 | |
| 409 | func TestOpenSubscriptionFromURL(t *testing.T) { |
| 410 | cleanup := setup.FakeGCPDefaultCredentials(t) |
| 411 | defer cleanup() |
| 412 | |
| 413 | tests := []struct { |
| 414 | URL string |
| 415 | WantErr bool |
| 416 | }{ |
| 417 | // OK, short form. |
| 418 | {"gcppubsub://myproject/mysub", false}, |
| 419 | // OK, long form. |
| 420 | {"gcppubsub://projects/myproject/subscriptions/mysub", false}, |
| 421 | // Invalid parameter. |
| 422 | {"gcppubsub://myproject/mysub?param=value", true}, |
| 423 | // Valid max_recv_batch_size |
| 424 | {"gcppubsub://projects/myproject/subscriptions/mysub?max_recv_batch_size=1", false}, |
| 425 | // Invalid max_recv_batch_size |
| 426 | {"gcppubsub://projects/myproject/subscriptions/mysub?max_recv_batch_size=0", true}, |
| 427 | // Invalid max_recv_batch_size |
| 428 | {"gcppubsub://projects/myproject/subscriptions/mysub?max_recv_batch_size=1001", true}, |
| 429 | // Valid nacklazy |
| 430 | {"gcppubsub://projects/myproject/subscriptions/mysub?nacklazy=true", false}, |
| 431 | // Invalid nacklazy |
| 432 | {"gcppubsub://projects/myproject/subscriptions/mysub?nacklazy=foo", true}, |
| 433 | } |
| 434 | |
| 435 | ctx := context.Background() |
| 436 | for _, test := range tests { |
| 437 | sub, err := pubsub.OpenSubscription(ctx, test.URL) |
| 438 | if (err != nil) != test.WantErr { |
| 439 | t.Errorf("%s: got error %v, want error %v", test.URL, err, test.WantErr) |
| 440 | } |
| 441 | if sub != nil { |
| 442 | sub.Shutdown(ctx) |
| 443 | } |
| 444 | } |
| 445 | } |
nothing calls this directly
no test coverage detected