1// Copyright 2020 Google LLC 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// https://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15// Code generated by gapic-generator. DO NOT EDIT. 16 17package pubsub 18 19import ( 20 "context" 21 "fmt" 22 "strconv" 23 "testing" 24 "time" 25 26 "cloud.google.com/go/internal/testutil" 27 "google.golang.org/api/iterator" 28 "google.golang.org/api/option" 29 pubsubpb "google.golang.org/genproto/googleapis/pubsub/v1" 30) 31 32var _ = fmt.Sprintf 33var _ = iterator.Done 34var _ = strconv.FormatUint 35var _ = time.Now 36 37func TestPublisherSmoke(t *testing.T) { 38 if testing.Short() { 39 t.Skip("skipping smoke test in short mode") 40 } 41 ctx := context.Background() 42 ts := testutil.TokenSource(ctx, DefaultAuthScopes()...) 43 if ts == nil { 44 t.Skip("Integration tests skipped. See CONTRIBUTING.md for details") 45 } 46 47 projectId := testutil.ProjID() 48 _ = projectId 49 50 c, err := NewPublisherClient(ctx, option.WithTokenSource(ts)) 51 if err != nil { 52 t.Fatal(err) 53 } 54 55 var formattedProject string = fmt.Sprintf("projects/%s", projectId) 56 var request = &pubsubpb.ListTopicsRequest{ 57 Project: formattedProject, 58 } 59 60 iter := c.ListTopics(ctx, request) 61 if _, err := iter.Next(); err != nil && err != iterator.Done { 62 t.Error(err) 63 } 64} 65