forked from mcardosos/azure-storage-go
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstorageservice_test.go
85 lines (72 loc) · 1.81 KB
/
storageservice_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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package storage
import chk "gopkg.in/check.v1"
type StorageSuite struct{}
var _ = chk.Suite(&StorageSuite{})
// This tests use the Table service, but could also use any other service
func (s *StorageSuite) TestGetServiceProperties(c *chk.C) {
cli := getTableClient(c)
rec := cli.client.appendRecorder(c)
defer rec.Stop()
sp, err := cli.GetServiceProperties()
c.Assert(err, chk.IsNil)
c.Assert(sp, chk.NotNil)
}
func (s *StorageSuite) TestSetServiceProperties(c *chk.C) {
cli := getTableClient(c)
rec := cli.client.appendRecorder(c)
t := true
num := 7
rp := RetentionPolicy{
Enabled: true,
Days: &num,
}
m := Metrics{
Version: "1.0",
Enabled: true,
IncludeAPIs: &t,
RetentionPolicy: &rp,
}
spInput := ServiceProperties{
Logging: &Logging{
Version: "1.0",
Delete: true,
Read: false,
Write: true,
RetentionPolicy: &rp,
},
HourMetrics: &m,
MinuteMetrics: &m,
Cors: &Cors{
CorsRule: []CorsRule{
{
AllowedOrigins: "*",
AllowedMethods: "GET,PUT",
MaxAgeInSeconds: 500,
ExposedHeaders: "x-ms-meta-customheader,x-ms-meta-data*",
AllowedHeaders: "x-ms-meta-customheader,x-ms-meta-target*",
},
},
},
}
err := cli.SetServiceProperties(spInput)
c.Assert(err, chk.IsNil)
spOutput, err := cli.GetServiceProperties()
c.Assert(err, chk.IsNil)
c.Assert(spOutput, chk.NotNil)
c.Assert(*spOutput, chk.DeepEquals, spInput)
rec.Stop()
// Back to defaults
defaultRP := RetentionPolicy{
Enabled: false,
Days: nil,
}
m.Enabled = false
m.IncludeAPIs = nil
m.RetentionPolicy = &defaultRP
spInput.Logging.Delete = false
spInput.Logging.Read = false
spInput.Logging.Write = false
spInput.Logging.RetentionPolicy = &defaultRP
spInput.Cors = &Cors{nil}
cli.SetServiceProperties(spInput)
}