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