Debian Codegraph @

storage/2017-07-29/blob/blobs/blob_append_test.go

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 package blobsscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/
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/2017-07-29/blob/containersscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/containers`/"
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 TestAppendBlobLifecyclescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/TestAppendBlobLifecycle().(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
21 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().())
22 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().())
23 containerName := fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.13 fmt/Sprintf().("cont-%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().())
24 fileName := "append-blob.txt"
25
•26 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`/.BlobStoragescip-go gomod github.com/Azure/azure-sdk-for-go v68.0.0 `github.com/Azure/azure-sdk-for-go/profiles/latest/storage/mgmt/storage`/BlobStorage.)
27 if err != nil {
28 t.Fatalscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatal().(err)
29 }
30 defer client.DestroyTestResourcesscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/testhelpers`/Client#DestroyTestResources().(ctx, resourceGroup, accountName)
31
32 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.)
33 containersClient := containersscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/containers`/.NewWithEnvironmentscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/containers`/NewWithEnvironment().(client.Environmentscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/testhelpers`/Client#Environment.)
34 containersClient.Clientscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/containers`/Client#Client. = client.PrepareWithAuthorizerscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/testhelpers`/Client#PrepareWithAuthorizer().(containersClient.Clientscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/containers`/Client#Client., storageAuth)
35
36 _, err = containersClient.Createscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/containers`/Client#Create().(ctx, accountName, containerName, containersscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/containers`/.CreateInputscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/containers`/CreateInput#{})
37 if err != nil {
38 t.Fatalscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatal().(fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.13 fmt/Errorf().("Error creating: %s", err))
39 }
40 defer containersClient.Deletescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/containers`/Client#Delete().(ctx, accountName, containerName)
41
42 blobClient := NewWithEnvironmentscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/NewWithEnvironment().(client.Environmentscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/testhelpers`/Client#Environment.)
43 blobClient.Clientscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/Client#Client. = client.PrepareWithAuthorizerscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/testhelpers`/Client#PrepareWithAuthorizer().(blobClient.Clientscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/Client#Client., storageAuth)
44
45 t.Logfscip-go gomod github.com/golang/go/src go1.13 testing/common#Logf().("[DEBUG] Putting Append Blob..")
46 if _, err := blobClient.PutAppendBlobscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/Client#PutAppendBlob().(ctx, accountName, containerName, fileName, PutAppendBlobInputscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/PutAppendBlobInput#{}); err != nil {
47 t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("Error putting append blob: %s", err)
48 }
49
50 t.Logfscip-go gomod github.com/golang/go/src go1.13 testing/common#Logf().("[DEBUG] Retrieving Properties..")
51 props, err := blobClient.GetPropertiesscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/Client#GetProperties().(ctx, accountName, containerName, fileName, GetPropertiesInputscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/GetPropertiesInput#{})
52 if err != nil {
53 t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("Error retrieving properties: %s", err)
54 }
55 if props.ContentLengthscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/GetPropertiesResult#ContentLength. != 0 {
56 t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("Expected Content-Length to be 0 but it was %d", props.ContentLengthscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/GetPropertiesResult#ContentLength.)
57 }
58
59 t.Logfscip-go gomod github.com/golang/go/src go1.13 testing/common#Logf().("[DEBUG] Appending First Block..")
60 appendInput := AppendBlockInputscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/AppendBlockInput#{
61 Contentscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/AppendBlockInput#Content.: &[]byte{
62 12,
63 48,
64 93,
65 76,
66 29,
67 10,
68 },
69 }
70 if _, err := blobClient.AppendBlockscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/Client#AppendBlock().(ctx, accountName, containerName, fileName, appendInput); err != nil {
71 t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("Error appending first block: %s", err)
72 }
73
74 t.Logfscip-go gomod github.com/golang/go/src go1.13 testing/common#Logf().("[DEBUG] Re-Retrieving Properties..")
75 props, err = blobClient.GetPropertiesscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/Client#GetProperties().(ctx, accountName, containerName, fileName, GetPropertiesInputscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/GetPropertiesInput#{})
76 if err != nil {
77 t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("Error retrieving properties: %s", err)
78 }
79 if props.ContentLengthscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/GetPropertiesResult#ContentLength. != 6 {
80 t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("Expected Content-Length to be 6 but it was %d", props.ContentLengthscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/GetPropertiesResult#ContentLength.)
81 }
82
83 t.Logfscip-go gomod github.com/golang/go/src go1.13 testing/common#Logf().("[DEBUG] Appending Second Block..")
84 appendInput = AppendBlockInputscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/AppendBlockInput#{
85 Contentscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/AppendBlockInput#Content.: &[]byte{
86 92,
87 62,
88 64,
89 47,
90 83,
91 77,
92 },
93 }
94 if _, err := blobClient.AppendBlockscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/Client#AppendBlock().(ctx, accountName, containerName, fileName, appendInput); err != nil {
95 t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("Error appending Second block: %s", err)
96 }
97
98 t.Logfscip-go gomod github.com/golang/go/src go1.13 testing/common#Logf().("[DEBUG] Re-Retrieving Properties..")
99 props, err = blobClient.GetPropertiesscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/Client#GetProperties().(ctx, accountName, containerName, fileName, GetPropertiesInputscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/GetPropertiesInput#{})
100 if err != nil {
101 t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("Error retrieving properties: %s", err)
102 }
103 if props.ContentLengthscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/GetPropertiesResult#ContentLength. != 12 {
104 t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("Expected Content-Length to be 12 but it was %d", props.ContentLengthscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/GetPropertiesResult#ContentLength.)
105 }
106
107 t.Logfscip-go gomod github.com/golang/go/src go1.13 testing/common#Logf().("[DEBUG] Acquiring Lease..")
108 leaseDetails, err := blobClient.AcquireLeasescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/Client#AcquireLease().(ctx, accountName, containerName, fileName, AcquireLeaseInputscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/AcquireLeaseInput#{
109 LeaseDurationscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/AcquireLeaseInput#LeaseDuration.: -1,
110 })
111 if err != nil {
112 t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("Error acquiring Lease: %s", err)
113 }
114 t.Logfscip-go gomod github.com/golang/go/src go1.13 testing/common#Logf().("[DEBUG] Lease ID is %q", leaseDetails.LeaseIDscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/AcquireLeaseResult#LeaseID.)
115
116 t.Logfscip-go gomod github.com/golang/go/src go1.13 testing/common#Logf().("[DEBUG] Appending Third Block..")
117 appendInput = AppendBlockInputscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/AppendBlockInput#{
118 Contentscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/AppendBlockInput#Content.: &[]byte{
119 64,
120 35,
121 28,
122 93,
123 11,
124 23,
125 },
126 LeaseIDscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/AppendBlockInput#LeaseID.: &leaseDetails.LeaseIDscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/AcquireLeaseResult#LeaseID.,
127 }
128 if _, err := blobClient.AppendBlockscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/Client#AppendBlock().(ctx, accountName, containerName, fileName, appendInput); err != nil {
129 t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("Error appending Third block: %s", err)
130 }
131
132 t.Logfscip-go gomod github.com/golang/go/src go1.13 testing/common#Logf().("[DEBUG] Re-Retrieving Properties..")
133 props, err = blobClient.GetPropertiesscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/Client#GetProperties().(ctx, accountName, containerName, fileName, GetPropertiesInputscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/GetPropertiesInput#{
134 LeaseIDscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/GetPropertiesInput#LeaseID.: &leaseDetails.LeaseIDscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/AcquireLeaseResult#LeaseID.,
135 })
136 if err != nil {
137 t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("Error retrieving properties: %s", err)
138 }
139 if props.ContentLengthscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/GetPropertiesResult#ContentLength. != 18 {
140 t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("Expected Content-Length to be 18 but it was %d", props.ContentLengthscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/GetPropertiesResult#ContentLength.)
141 }
142
143 t.Logfscip-go gomod github.com/golang/go/src go1.13 testing/common#Logf().("[DEBUG] Breaking Lease..")
144 breakLeaseInput := BreakLeaseInputscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/BreakLeaseInput#{
145 LeaseIDscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/BreakLeaseInput#LeaseID.: leaseDetails.LeaseIDscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/AcquireLeaseResult#LeaseID.,
146 }
147 if _, err := blobClient.BreakLeasescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/Client#BreakLease().(ctx, accountName, containerName, fileName, breakLeaseInput); err != nil {
148 t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("Error breaking lease: %s", err)
149 }
150
151 t.Logfscip-go gomod github.com/golang/go/src go1.13 testing/common#Logf().("[DEBUG] Deleting Lease..")
152 if _, err := blobClient.Deletescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/Client#Delete().(ctx, accountName, containerName, fileName, DeleteInputscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2017-07-29/blob/blobs`/DeleteInput#{}); err != nil {
153 t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("Error deleting: %s", err)
154 }
155 }