blob: 7735e028eac2fbb856fa8fe316b290920dfd5145 [file] [log] [blame]
Mikko Valkonen20de7802016-10-24 22:25:01 +03001package testing
2
3import (
Mikko Valkonend887d2a2016-10-25 21:00:09 +03004 "github.com/gophercloud/gophercloud"
Mikko Valkonen20de7802016-10-24 22:25:01 +03005 "github.com/gophercloud/gophercloud/openstack/sharedfilesystems/v2/shares"
6 th "github.com/gophercloud/gophercloud/testhelper"
7 "github.com/gophercloud/gophercloud/testhelper/client"
8 "testing"
Mikko Valkonend887d2a2016-10-25 21:00:09 +03009 "time"
Mikko Valkonen20de7802016-10-24 22:25:01 +030010)
11
12func TestCreate(t *testing.T) {
13 th.SetupHTTP()
14 defer th.TeardownHTTP()
15
16 MockCreateResponse(t)
17
18 options := &shares.CreateOpts{Size: 1, Name: "my_test_share", ShareProto: "NFS"}
19 n, err := shares.Create(client.ServiceClient(), options).Extract()
20
21 th.AssertNoErr(t, err)
22 th.AssertEquals(t, n.Name, "my_test_share")
23 th.AssertEquals(t, n.Size, 1)
24 th.AssertEquals(t, n.ShareProto, "NFS")
25}
Mikko Valkonen4c108b52016-10-24 23:11:25 +030026
27func TestDelete(t *testing.T) {
28 th.SetupHTTP()
29 defer th.TeardownHTTP()
30
31 MockDeleteResponse(t)
32
33 result := shares.Delete(client.ServiceClient(), shareID)
34 th.AssertNoErr(t, result.Err)
35}
Mikko Valkonend887d2a2016-10-25 21:00:09 +030036
37func TestGet(t *testing.T) {
38 th.SetupHTTP()
39 defer th.TeardownHTTP()
40
41 MockGetResponse(t)
42
43 s, err := shares.Get(client.ServiceClient(), shareID).Extract()
44 th.AssertNoErr(t, err)
45 th.AssertDeepEquals(t, s, &shares.Share{
46 AvailabilityZone: "nova",
47 ShareNetworkID: "713df749-aac0-4a54-af52-10f6c991e80c",
48 ShareServerID: "e268f4aa-d571-43dd-9ab3-f49ad06ffaef",
49 SnapshotID: "",
50 ID: shareID,
51 Size: 1,
52 ShareType: "25747776-08e5-494f-ab40-a64b9d20d8f7",
53 ShareTypeName: "default",
54 ConsistencyGroupID: "9397c191-8427-4661-a2e8-b23820dc01d4",
55 ProjectID: "16e1ab15c35a457e9c2b2aa189f544e1",
56 Metadata: map[string]string{
57 "project": "my_app",
58 "aim": "doc",
59 },
60 Status: "available",
61 Description: "My custom share London",
62 Host: "manila2@generic1#GENERIC1",
63 HasReplicas: false,
64 ReplicationType: "",
65 TaskState: "",
66 SnapshotSupport: true,
67 Name: "my_test_share",
68 CreatedAt: gophercloud.JSONRFC3339MilliNoZ(time.Date(
69 2015, time.September, 18, 10, 25, 24, 0, time.UTC)),
70 ShareProto: "NFS",
71 VolumeType: "default",
72 SourceCgsnapshotMemberID: "",
73 IsPublic: true,
74 Links: []map[string]string{
75 {
76 "href": "http://172.18.198.54:8786/v2/16e1ab15c35a457e9c2b2aa189f544e1/shares/011d21e2-fbc3-4e4a-9993-9ea223f73264",
77 "rel": "self",
78 },
79 {
80 "href": "http://172.18.198.54:8786/16e1ab15c35a457e9c2b2aa189f544e1/shares/011d21e2-fbc3-4e4a-9993-9ea223f73264",
81 "rel": "bookmark",
82 },
83 },
84 })
85}