Debian Codegraph @

storage/2018-03-28/queue/messages/lifecycle_test.go

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 package messagesscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/messages`/
2
3 import (
4 "contextscip-go gomod github.com/golang/go/src go1.13 context/"
5 "fmtscip-go gomod github.com/golang/go/src go1.13 fmt/"
6 "testingscip-go gomod github.com/golang/go/src go1.13 testing/"
7
8 "github.com/Azure/azure-sdk-for-go/profiles/latest/storage/mgmt/storagescip-go gomod github.com/Azure/azure-sdk-for-go v68.0.0 `github.com/Azure/azure-sdk-for-go/profiles/latest/storage/mgmt/storage`/"
9 "github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/queuesscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/queues`/"
10 "github.com/tombuildsstuff/giovanni/storage/internal/authscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/internal/auth`/"
11 "github.com/tombuildsstuff/giovanni/testhelpersscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/testhelpers`/"
12 )
13
14 func TestLifeCyclescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/messages`/TestLifeCycle().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) {
15 client, err := testhelpersscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/testhelpers`/.Buildscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/testhelpers`/Build().(t)
16 if err != nil {
17 t.Fatalscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatal().(err)
18 }
19 ctx := contextscip-go gomod github.com/golang/go/src go1.13 context/.TODOscip-go gomod github.com/golang/go/src go1.13 context/TODO().()
20 resourceGroup := fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.13 fmt/Sprintf().("acctestrg-%d", testhelpersscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/testhelpers`/.RandomIntscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/testhelpers`/RandomInt().())
21 accountName := fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.13 fmt/Sprintf().("acctestsa%s", testhelpersscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/testhelpers`/.RandomStringscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/testhelpers`/RandomString().())
22 queueName := fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.13 fmt/Sprintf().("queue-%d", testhelpersscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/testhelpers`/.RandomIntscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/testhelpers`/RandomInt().())
23
•24 testData, err := client.BuildTestResourcesscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/testhelpers`/Client#BuildTestResources().(ctx, resourceGroup, accountName, storagescip-go gomod github.com/Azure/azure-sdk-for-go v68.0.0 `github.com/Azure/azure-sdk-for-go/profiles/latest/storage/mgmt/storage`/.Storagescip-go gomod github.com/Azure/azure-sdk-for-go v68.0.0 `github.com/Azure/azure-sdk-for-go/profiles/latest/storage/mgmt/storage`/Storage.)
25 if err != nil {
26 t.Fatalscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatal().(err)
27 }
28 defer client.DestroyTestResourcesscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/testhelpers`/Client#DestroyTestResources().(ctx, resourceGroup, accountName)
29
30 queuesClient := queuesscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/queues`/.NewWithEnvironmentscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/queues`/NewWithEnvironment().(client.Environmentscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/testhelpers`/Client#Environment.)
31 queuesClient.Clientscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/queues`/Client#Client. = client.PrepareWithStorageResourceManagerAuthscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/testhelpers`/Client#PrepareWithStorageResourceManagerAuth().(queuesClient.Clientscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/queues`/Client#Client.)
32
33 storageAuth := authscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/internal/auth`/.NewSharedKeyLiteAuthorizerscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/internal/auth`/NewSharedKeyLiteAuthorizer().(accountName, testData.StorageAccountKeyscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/testhelpers`/TestResources#StorageAccountKey.)
34 messagesClient := NewWithEnvironmentscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/messages`/NewWithEnvironment().(client.Environmentscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/testhelpers`/Client#Environment.)
35 messagesClient.Clientscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/messages`/Client#Client. = client.PrepareWithAuthorizerscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/testhelpers`/Client#PrepareWithAuthorizer().(messagesClient.Clientscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/messages`/Client#Client., storageAuth)
36
37 _, err = queuesClient.Createscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/queues`/Client#Create().(ctx, accountName, queueName, map[string]string{})
38 if err != nil {
39 t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("Error creating queue: %s", err)
40 }
41 defer queuesClient.Deletescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/queues`/Client#Delete().(ctx, accountName, queueName)
42
43 input := PutInputscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/messages`/PutInput#{
44 Messagescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/messages`/PutInput#Message.: "ohhai",
45 }
46 putResp, err := messagesClient.Putscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/messages`/Client#Put().(ctx, accountName, queueName, input)
47 if err != nil {
48 t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("Error putting message in queue: %s", err)
49 }
50
51 messageId := (*putResp.QueueMessagesscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/messages`/QueueMessagesListResult#QueueMessages.)[0].MessageIdscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/messages`/QueueMessageResponse#MessageId.
52 popReceipt := (*putResp.QueueMessagesscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/messages`/QueueMessagesListResult#QueueMessages.)[0].PopReceiptscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/messages`/QueueMessageResponse#PopReceipt.
53
54 _, err = messagesClient.Updatescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/messages`/Client#Update().(ctx, accountName, queueName, messageId, UpdateInputscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/messages`/UpdateInput#{
55 PopReceiptscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/messages`/UpdateInput#PopReceipt.: popReceipt,
56 Messagescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/messages`/UpdateInput#Message.: "Updated message",
57 VisibilityTimeoutscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/messages`/UpdateInput#VisibilityTimeout.: 65,
58 })
59 if err != nil {
60 t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("Error updating: %s", err)
61 }
62
63 for i := 0; i < 5; i++ {
64 input := PutInputscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/messages`/PutInput#{
65 Messagescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/messages`/PutInput#Message.: fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.13 fmt/Sprintf().("Message %d", i),
66 }
67 _, err := messagesClient.Putscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/messages`/Client#Put().(ctx, accountName, queueName, input)
68 if err != nil {
69 t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("Error putting message %d in queue: %s", i, err)
70 }
71 }
72
73 peakedMessages, err := messagesClient.Peekscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/messages`/Client#Peek().(ctx, accountName, queueName, 3)
74 if err != nil {
75 t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("Error peaking messages: %s", err)
76 }
77
78 for _, v := range *peakedMessages.QueueMessagesscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/messages`/QueueMessagesListResult#QueueMessages. {
79 t.Logfscip-go gomod github.com/golang/go/src go1.13 testing/common#Logf().("Message: %q", v.MessageIdscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/messages`/QueueMessageResponse#MessageId.)
80 }
81
82 retrievedMessages, err := messagesClient.Getscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/messages`/Client#Get().(ctx, accountName, queueName, 6, GetInputscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/messages`/GetInput#{})
83 if err != nil {
84 t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("Error retrieving messages: %s", err)
85 }
86
87 for _, v := range *retrievedMessages.QueueMessagesscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/messages`/QueueMessagesListResult#QueueMessages. {
88 t.Logfscip-go gomod github.com/golang/go/src go1.13 testing/common#Logf().("Message: %q", v.MessageIdscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/messages`/QueueMessageResponse#MessageId.)
89
90 _, err = messagesClient.Deletescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/messages`/Client#Delete().(ctx, accountName, queueName, v.MessageIdscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/messages`/QueueMessageResponse#MessageId., v.PopReceiptscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/queue/messages`/QueueMessageResponse#PopReceipt.)
91 if err != nil {
92 t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("Error deleting message from queue: %s", err)
93 }
94 }
95 }