mirror of
https://github.com/rclone/rclone.git
synced 2025-12-26 13:13:31 +00:00
vendor: update all dependencies to latest versions
This commit is contained in:
86
vendor/cloud.google.com/go/pubsub/integration_test.go
generated
vendored
86
vendor/cloud.google.com/go/pubsub/integration_test.go
generated
vendored
@@ -31,6 +31,11 @@ import (
|
||||
"google.golang.org/api/option"
|
||||
)
|
||||
|
||||
var (
|
||||
topicIDs = testutil.NewUIDSpace("topic")
|
||||
subIDs = testutil.NewUIDSpace("sub")
|
||||
)
|
||||
|
||||
// messageData is used to hold the contents of a message so that it can be compared against the contents
|
||||
// of another message without regard to irrelevant fields.
|
||||
type messageData struct {
|
||||
@@ -47,8 +52,7 @@ func extractMessageData(m *Message) *messageData {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAll(t *testing.T) {
|
||||
t.Parallel()
|
||||
func integrationTestClient(t *testing.T, ctx context.Context) *Client {
|
||||
if testing.Short() {
|
||||
t.Skip("Integration tests skipped in short mode")
|
||||
}
|
||||
@@ -56,30 +60,31 @@ func TestAll(t *testing.T) {
|
||||
if projID == "" {
|
||||
t.Skip("Integration tests skipped. See CONTRIBUTING.md for details")
|
||||
}
|
||||
ctx := context.Background()
|
||||
ts := testutil.TokenSource(ctx, ScopePubSub, ScopeCloudPlatform)
|
||||
if ts == nil {
|
||||
t.Skip("Integration tests skipped. See CONTRIBUTING.md for details")
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
topicName := fmt.Sprintf("topic-%d", now.Unix())
|
||||
subName := fmt.Sprintf("subscription-%d", now.Unix())
|
||||
|
||||
client, err := NewClient(ctx, projID, option.WithTokenSource(ts))
|
||||
if err != nil {
|
||||
t.Fatalf("Creating client error: %v", err)
|
||||
}
|
||||
return client
|
||||
}
|
||||
|
||||
func TestAll(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
client := integrationTestClient(t, ctx)
|
||||
defer client.Close()
|
||||
|
||||
var topic *Topic
|
||||
if topic, err = client.CreateTopic(ctx, topicName); err != nil {
|
||||
topic, err := client.CreateTopic(ctx, topicIDs.New())
|
||||
if err != nil {
|
||||
t.Errorf("CreateTopic error: %v", err)
|
||||
}
|
||||
defer topic.Stop()
|
||||
|
||||
var sub *Subscription
|
||||
if sub, err = client.CreateSubscription(ctx, subName, SubscriptionConfig{Topic: topic}); err != nil {
|
||||
if sub, err = client.CreateSubscription(ctx, subIDs.New(), SubscriptionConfig{Topic: topic}); err != nil {
|
||||
t.Errorf("CreateSub error: %v", err)
|
||||
}
|
||||
|
||||
@@ -88,7 +93,7 @@ func TestAll(t *testing.T) {
|
||||
t.Fatalf("TopicExists error: %v", err)
|
||||
}
|
||||
if !exists {
|
||||
t.Errorf("topic %s should exist, but it doesn't", topic)
|
||||
t.Errorf("topic %v should exist, but it doesn't", topic)
|
||||
}
|
||||
|
||||
exists, err = sub.Exists(ctx)
|
||||
@@ -96,10 +101,10 @@ func TestAll(t *testing.T) {
|
||||
t.Fatalf("SubExists error: %v", err)
|
||||
}
|
||||
if !exists {
|
||||
t.Errorf("subscription %s should exist, but it doesn't", subName)
|
||||
t.Errorf("subscription %s should exist, but it doesn't", sub.ID())
|
||||
}
|
||||
|
||||
msgs := []*Message{}
|
||||
var msgs []*Message
|
||||
for i := 0; i < 10; i++ {
|
||||
text := fmt.Sprintf("a message with an index %d", i)
|
||||
attrs := make(map[string]string)
|
||||
@@ -275,37 +280,18 @@ func testIAM(ctx context.Context, h *iam.Handle, permission string) (msg string,
|
||||
func TestSubscriptionUpdate(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
if testing.Short() {
|
||||
t.Skip("Integration tests skipped in short mode")
|
||||
}
|
||||
projID := testutil.ProjID()
|
||||
if projID == "" {
|
||||
t.Skip("Integration tests skipped. See CONTRIBUTING.md for details.")
|
||||
}
|
||||
ts := testutil.TokenSource(ctx, ScopePubSub, ScopeCloudPlatform)
|
||||
if ts == nil {
|
||||
t.Skip("Integration tests skipped. See CONTRIBUTING.md for details")
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
topicName := fmt.Sprintf("topic-modify-%d", now.Unix())
|
||||
subName := fmt.Sprintf("subscription-modify-%d", now.Unix())
|
||||
|
||||
client, err := NewClient(ctx, projID, option.WithTokenSource(ts))
|
||||
if err != nil {
|
||||
t.Fatalf("Creating client error: %v", err)
|
||||
}
|
||||
client := integrationTestClient(t, ctx)
|
||||
defer client.Close()
|
||||
|
||||
var topic *Topic
|
||||
if topic, err = client.CreateTopic(ctx, topicName); err != nil {
|
||||
topic, err := client.CreateTopic(ctx, topicIDs.New())
|
||||
if err != nil {
|
||||
t.Fatalf("CreateTopic error: %v", err)
|
||||
}
|
||||
defer topic.Stop()
|
||||
defer topic.Delete(ctx)
|
||||
|
||||
var sub *Subscription
|
||||
if sub, err = client.CreateSubscription(ctx, subName, SubscriptionConfig{Topic: topic}); err != nil {
|
||||
if sub, err = client.CreateSubscription(ctx, subIDs.New(), SubscriptionConfig{Topic: topic}); err != nil {
|
||||
t.Fatalf("CreateSub error: %v", err)
|
||||
}
|
||||
defer sub.Delete(ctx)
|
||||
@@ -318,6 +304,7 @@ func TestSubscriptionUpdate(t *testing.T) {
|
||||
t.Fatalf("got %+v, want empty PushConfig")
|
||||
}
|
||||
// Add a PushConfig.
|
||||
projID := testutil.ProjID()
|
||||
pc := PushConfig{
|
||||
Endpoint: "https://" + projID + ".appspot.com/_ah/push-handlers/push",
|
||||
Attributes: map[string]string{"x-goog-version": "v1"},
|
||||
@@ -349,3 +336,28 @@ func TestSubscriptionUpdate(t *testing.T) {
|
||||
t.Fatal("got nil, wanted error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPublicTopic(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
client := integrationTestClient(t, ctx)
|
||||
defer client.Close()
|
||||
|
||||
sub, err := client.CreateSubscription(ctx, subIDs.New(), SubscriptionConfig{
|
||||
Topic: client.TopicInProject("taxirides-realtime", "pubsub-public-data"),
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer sub.Delete(ctx)
|
||||
// Confirm that Receive works. It doesn't matter if we actually get any
|
||||
// messages.
|
||||
ctxt, cancel := context.WithTimeout(ctx, 5*time.Second)
|
||||
err = sub.Receive(ctxt, func(_ context.Context, msg *Message) {
|
||||
msg.Ack()
|
||||
cancel()
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user