(t *testing.T)
| 329 | } |
| 330 | |
| 331 | func TestOpenSubscription(t *testing.T) { |
| 332 | ctx := context.Background() |
| 333 | creds, err := setup.FakeGCPCredentials(ctx) |
| 334 | if err != nil { |
| 335 | t.Fatal(err) |
| 336 | } |
| 337 | projID, err := gcp.DefaultProjectID(creds) |
| 338 | if err != nil { |
| 339 | t.Fatal(err) |
| 340 | } |
| 341 | conn, cleanup, err := Dial(ctx, gcp.CredentialsTokenSource(creds)) |
| 342 | if err != nil { |
| 343 | t.Fatal(err) |
| 344 | } |
| 345 | defer cleanup() |
| 346 | sc, err := SubscriberClient(ctx, conn) |
| 347 | if err != nil { |
| 348 | t.Fatal(err) |
| 349 | } |
| 350 | sub := OpenSubscription(sc, projID, "my-subscription", nil) |
| 351 | defer sub.Shutdown(ctx) |
| 352 | _, err = sub.Receive(ctx) |
| 353 | if err == nil { |
| 354 | t.Error("got nil, want error") |
| 355 | } |
| 356 | |
| 357 | // Repeat with OpenSubscriptionByPath. |
| 358 | sub, err = OpenSubscriptionByPath(sc, path.Join("projects", string(projID), "subscriptions", "my-subscription"), nil) |
| 359 | if err != nil { |
| 360 | t.Fatal(err) |
| 361 | } |
| 362 | defer sub.Shutdown(ctx) |
| 363 | _, err = sub.Receive(ctx) |
| 364 | if err == nil { |
| 365 | t.Error("got nil, want error") |
| 366 | } |
| 367 | |
| 368 | // Try an invalid path. |
| 369 | _, err = OpenSubscriptionByPath(sc, "my-subscription", nil) |
| 370 | if err == nil { |
| 371 | t.Error("got nil, want error") |
| 372 | } |
| 373 | } |
| 374 | |
| 375 | func TestOpenTopicFromURL(t *testing.T) { |
| 376 | cleanup := setup.FakeGCPDefaultCredentials(t) |
nothing calls this directly
no test coverage detected