Debian Codegraph @

storage/2018-03-28/file/files/range_put_file_test.go

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 package filesscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/files`/
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 "osscip-go gomod github.com/golang/go/src go1.13 os/"
7 "testingscip-go gomod github.com/golang/go/src go1.13 testing/"
8
9 "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`/"
10 "github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/sharesscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/shares`/"
11 "github.com/tombuildsstuff/giovanni/storage/internal/authscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/internal/auth`/"
12 "github.com/tombuildsstuff/giovanni/testhelpersscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/testhelpers`/"
13 )
14
15 func TestPutSmallFilescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/files`/TestPutSmallFile().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) {
16 // the purpose of this test is to ensure that a small file (< 4MB) is a single chunk
17 testPutFilescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/files`/testPutFile().(t, "small-file.png", "image/png")
18 }
19
20 func TestPutLargeFilescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/files`/TestPutLargeFile().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) {
21 // the purpose of this test is to ensure that large files (> 4MB) are chunked
22 testPutFilescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/files`/testPutFile().(t, "blank-large-file.dmg", "application/x-apple-diskimage")
23 }
24
25 func testPutFilescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/files`/testPutFile().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#, fileName string, contentType string) {
26 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)
27 if err != nil {
28 t.Fatalscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatal().(err)
29 }
30 ctx := contextscip-go gomod github.com/golang/go/src go1.13 context/.TODOscip-go gomod github.com/golang/go/src go1.13 context/TODO().()
31 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().())
32 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().())
33 shareName := fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.13 fmt/Sprintf().("share-%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().())
34
•35 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.)
36 if err != nil {
37 t.Fatalscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatal().(err)
38 }
39 defer client.DestroyTestResourcesscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/testhelpers`/Client#DestroyTestResources().(ctx, resourceGroup, accountName)
40
41 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.)
42 sharesClient := sharesscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/shares`/.NewWithEnvironmentscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/shares`/NewWithEnvironment().(client.Environmentscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/testhelpers`/Client#Environment.)
43 sharesClient.Clientscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/shares`/Client#Client. = client.PrepareWithAuthorizerscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/testhelpers`/Client#PrepareWithAuthorizer().(sharesClient.Clientscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/shares`/Client#Client., storageAuth)
44
45 input := sharesscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/shares`/.CreateInputscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/shares`/CreateInput#{
46 QuotaInGBscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/shares`/CreateInput#QuotaInGB.: 10,
47 }
48 _, err = sharesClient.Createscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/shares`/Client#Create().(ctx, accountName, shareName, input)
49 if err != nil {
50 t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("Error creating fileshare: %s", err)
51 }
52 defer sharesClient.Deletescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/shares`/Client#Delete().(ctx, accountName, shareName, false)
53
54 filesClient := NewWithEnvironmentscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/files`/NewWithEnvironment().(client.Environmentscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/testhelpers`/Client#Environment.)
55 filesClient.Clientscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/files`/Client#Client. = client.PrepareWithAuthorizerscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/testhelpers`/Client#PrepareWithAuthorizer().(filesClient.Clientscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/files`/Client#Client., storageAuth)
56
57 // store files outside of this directory, since they're reused
58 file, err := osscip-go gomod github.com/golang/go/src go1.13 os/.Openscip-go gomod github.com/golang/go/src go1.13 os/Open().("../../../testdata/" + fileName)
59 if err != nil {
60 t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("Error opening: %s", err)
61 }
62
63 info, err := file.Statscip-go gomod github.com/golang/go/src go1.13 os/File#Stat().()
64 if err != nil {
65 t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("Error 'stat'-ing: %s", err)
66 }
67
68 t.Logfscip-go gomod github.com/golang/go/src go1.13 testing/common#Logf().("[DEBUG] Creating Top Level File..")
69 createFileInput := CreateInputscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/files`/CreateInput#{
70 ContentLengthscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/files`/CreateInput#ContentLength.: info.Sizescip-go gomod github.com/golang/go/src go1.13 `io/fs`/FileInfo#Size().(),
71 ContentTypescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/files`/CreateInput#ContentType.: &contentType,
72 }
73 if _, err := filesClient.Createscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/files`/Client#Create().(ctx, accountName, shareName, "", fileName, createFileInput); err != nil {
74 t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("Error creating Top-Level File: %s", err)
75 }
76
77 t.Logfscip-go gomod github.com/golang/go/src go1.13 testing/common#Logf().("[DEBUG] Uploading File..")
78 if err := filesClient.PutFilescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/files`/Client#PutFile().(ctx, accountName, shareName, "", fileName, file, 4); err != nil {
79 t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("Error uploading File: %s", err)
80 }
81
82 t.Logfscip-go gomod github.com/golang/go/src go1.13 testing/common#Logf().("[DEBUG] Deleting Top Level File..")
83 if _, err := filesClient.Deletescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/2018-03-28/file/files`/Client#Delete().(ctx, accountName, shareName, "", fileName); err != nil {
84 t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("Error deleting Top-Level File: %s", err)
85 }
86 }