Debian Codegraph @

storage/2018-11-09/datalakestore/filesystems/lifecycle_test.go

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 package filesystems
2
3 import (
4 "context"
5 "fmt"
6 "testing"
7
8 "github.com/Azure/azure-sdk-for-go/profiles/latest/storage/mgmt/storage"
9 "github.com/tombuildsstuff/giovanni/testhelpers"
10 )
11
12 func TestLifecycle(t *testing.T) {
13 client, err := testhelpers.Build(t)
14 if err != nil {
15 t.Fatal(err)
16 }
17 ctx := context.TODO()
18
19 resourceGroup := fmt.Sprintf("acctestrg-%d", testhelpers.RandomInt())
20 accountName := fmt.Sprintf("acctestsa%s", testhelpers.RandomString())
21 fileSystemName := fmt.Sprintf("acctestfs-%s", testhelpers.RandomString())
22
•23 if _, err = client.BuildTestResources(ctx, resourceGroup, accountName, storage.BlobStorage); err != nil {
24 t.Fatal(err)
25 }
26 defer client.DestroyTestResources(ctx, resourceGroup, accountName)
27 fileSystemsClient := NewWithEnvironment(client.Environment)
28 fileSystemsClient.Client = client.PrepareWithStorageResourceManagerAuth(fileSystemsClient.Client)
29
30 t.Logf("[DEBUG] Creating an empty File System..")
31 input := CreateInput{
32 Properties: map[string]string{
33 "hello": "aGVsbG8=",
34 },
35 }
36 if _, err = fileSystemsClient.Create(ctx, accountName, fileSystemName, input); err != nil {
37 t.Fatal(fmt.Errorf("Error creating: %s", err))
38 }
39
40 t.Logf("[DEBUG] Retrieving the Properties..")
41 props, err := fileSystemsClient.GetProperties(ctx, accountName, fileSystemName)
42 if err != nil {
43 t.Fatal(fmt.Errorf("Error getting properties: %s", err))
44 }
45
46 if len(props.Properties) != 1 {
47 t.Fatalf("Expected 1 properties by default but got %d", len(props.Properties))
48 }
49 if props.Properties["hello"] != "aGVsbG8=" {
50 t.Fatalf("Expected `hello` to be `aGVsbG8=` but got %q", props.Properties["hello"])
51 }
52
53 t.Logf("[DEBUG] Updating the properties..")
54 setInput := SetPropertiesInput{
55 Properties: map[string]string{
56 "hello": "d29uZGVybGFuZA==",
57 "private": "ZXll",
58 },
59 }
60 if _, err := fileSystemsClient.SetProperties(ctx, accountName, fileSystemName, setInput); err != nil {
61 t.Fatalf("Error setting properties: %s", err)
62 }
63
64 t.Logf("[DEBUG] Re-Retrieving the Properties..")
65 props, err = fileSystemsClient.GetProperties(ctx, accountName, fileSystemName)
66 if err != nil {
67 t.Fatal(fmt.Errorf("Error getting properties: %s", err))
68 }
69 if len(props.Properties) != 2 {
70 t.Fatalf("Expected 2 properties by default but got %d", len(props.Properties))
71 }
72 if props.Properties["hello"] != "d29uZGVybGFuZA==" {
73 t.Fatalf("Expected `hello` to be `d29uZGVybGFuZA==` but got %q", props.Properties["hello"])
74 }
75 if props.Properties["private"] != "ZXll" {
76 t.Fatalf("Expected `private` to be `ZXll` but got %q", props.Properties["private"])
77 }
78
79 t.Logf("[DEBUG] Deleting File System..")
80 if _, err := fileSystemsClient.Delete(ctx, accountName, fileSystemName); err != nil {
81 t.Fatalf("Error deleting: %s", err)
82 }
83 }