...

Source file src/cloud.google.com/go/pubsub/apiv1/ListTopics_smoke_test.go

Documentation: cloud.google.com/go/pubsub/apiv1

     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  
    17  package pubsub
    18  
    19  import (
    20  	"context"
    21  	"fmt"
    22  	"strconv"
    23  	"testing"
    24  	"time"
    25  
    26  	"cloud.google.com/go/internal/testutil"
    27  	"cloud.google.com/go/pubsub/apiv1/pubsubpb"
    28  	"google.golang.org/api/iterator"
    29  	"google.golang.org/api/option"
    30  )
    31  
    32  var _ = fmt.Sprintf
    33  var _ = iterator.Done
    34  var _ = strconv.FormatUint
    35  var _ = time.Now
    36  
    37  func 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  

View as plain text