-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathcreate_test.go
69 lines (56 loc) · 2.09 KB
/
create_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package filesystems
import (
"context"
"fmt"
"testing"
"time"
"github.com/hashicorp/go-azure-sdk/resource-manager/storage/2023-01-01/storageaccounts"
"github.com/hashicorp/go-azure-sdk/sdk/auth"
"github.com/tombuildsstuff/giovanni/storage/internal/testhelpers"
)
func TestCreateHasNoTagsByDefault(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Hour)
defer cancel()
client, err := testhelpers.Build(ctx, t)
if err != nil {
t.Fatal(err)
}
resourceGroup := fmt.Sprintf("acctestrg-%d", testhelpers.RandomInt())
accountName := fmt.Sprintf("acctestsa%s", testhelpers.RandomString())
fileSystemName := fmt.Sprintf("acctestfs-%s", testhelpers.RandomString())
testData, err := client.BuildTestResources(ctx, resourceGroup, accountName, storageaccounts.KindBlobStorage)
if err != nil {
t.Fatal(err)
}
defer client.DestroyTestResources(ctx, resourceGroup, accountName)
domainSuffix, ok := client.Environment.Storage.DomainSuffix()
if !ok {
t.Fatalf("storage didn't return a domain suffix for this environment")
}
fileSystemsClient, err := NewWithBaseUri(fmt.Sprintf("https://%s.%s.%s", accountName, "dfs", *domainSuffix))
if err != nil {
t.Fatalf("building client for environment: %+v", err)
}
if err := client.PrepareWithSharedKeyAuth(fileSystemsClient.Client, testData, auth.SharedKey); err != nil {
t.Fatalf("adding authorizer to client: %+v", err)
}
t.Logf("[DEBUG] Creating an empty File System..")
input := CreateInput{
Properties: map[string]string{},
}
if _, err = fileSystemsClient.Create(ctx, fileSystemName, input); err != nil {
t.Fatal(fmt.Errorf("Error creating: %s", err))
}
t.Logf("[DEBUG] Retrieving the Properties..")
props, err := fileSystemsClient.GetProperties(ctx, fileSystemName)
if err != nil {
t.Fatal(fmt.Errorf("Error getting properties: %s", err))
}
if len(props.Properties) != 0 {
t.Fatalf("Expected 0 properties by default but got %d", len(props.Properties))
}
t.Logf("[DEBUG] Deleting File System..")
if _, err := fileSystemsClient.Delete(ctx, fileSystemName); err != nil {
t.Fatalf("Error deleting: %s", err)
}
}