github.com/gophercloud/gophercloud@v1.11.0/openstack/sharedfilesystems/v2/messages/testing/fixtures_test.go (about) 1 package testing 2 3 import ( 4 "fmt" 5 "net/http" 6 "testing" 7 8 th "github.com/gophercloud/gophercloud/testhelper" 9 fake "github.com/gophercloud/gophercloud/testhelper/client" 10 ) 11 12 func MockDeleteResponse(t *testing.T) { 13 th.Mux.HandleFunc("/messages/messageID", func(w http.ResponseWriter, r *http.Request) { 14 th.TestMethod(t, r, "DELETE") 15 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 16 w.WriteHeader(http.StatusAccepted) 17 }) 18 } 19 20 func MockListResponse(t *testing.T) { 21 th.Mux.HandleFunc("/messages", func(w http.ResponseWriter, r *http.Request) { 22 th.TestMethod(t, r, "GET") 23 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 24 25 w.Header().Add("Content-Type", "application/json") 26 w.WriteHeader(http.StatusOK) 27 28 fmt.Fprintf(w, ` 29 { 30 "messages": [ 31 { 32 "resource_id": "0d0b883f-95ef-406c-b930-55612ee48a6d", 33 "message_level": "ERROR", 34 "user_message": "create: Could not find an existing share server or allocate one on the share network provided. You may use a different share network, or verify the network details in the share network and retry your request. If this doesn't work, contact your administrator to troubleshoot issues with your network.", 35 "expires_at": "2019-01-06T08:53:38.000000", 36 "id": "143a6cc2-1998-44d0-8356-22070b0ebdaa", 37 "created_at": "2018-12-07T08:53:38.000000", 38 "detail_id": "004", 39 "request_id": "req-21767eee-22ca-40a4-b6c0-ae7d35cd434f", 40 "project_id": "a5e9d48232dc4aa59a716b5ced963584", 41 "resource_type": "SHARE", 42 "action_id": "002" 43 }, 44 { 45 "resource_id": "4336d74f-3bdc-4f27-9657-c01ec63680bf", 46 "message_level": "ERROR", 47 "user_message": "create: Could not find an existing share server or allocate one on the share network provided. You may use a different share network, or verify the network details in the share network and retry your request. If this doesn't work, contact your administrator to troubleshoot issues with your network.", 48 "expires_at": "2019-01-06T08:53:34.000000", 49 "id": "2076373e-13a7-4b84-9e67-15ce8cceaff8", 50 "created_at": "2018-12-07T08:53:34.000000", 51 "detail_id": "004", 52 "request_id": "req-957792ed-f38b-42db-a86a-850f815cbbe9", 53 "project_id": "a5e9d48232dc4aa59a716b5ced963584", 54 "resource_type": "SHARE", 55 "action_id": "002" 56 } 57 ] 58 }`) 59 }) 60 } 61 62 func MockFilteredListResponse(t *testing.T) { 63 th.Mux.HandleFunc("/messages", func(w http.ResponseWriter, r *http.Request) { 64 th.TestMethod(t, r, "GET") 65 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 66 67 w.Header().Add("Content-Type", "application/json") 68 w.WriteHeader(http.StatusOK) 69 70 fmt.Fprintf(w, ` 71 { 72 "messages": [ 73 { 74 "resource_id": "4336d74f-3bdc-4f27-9657-c01ec63680bf", 75 "message_level": "ERROR", 76 "user_message": "create: Could not find an existing share server or allocate one on the share network provided. You may use a different share network, or verify the network details in the share network and retry your request. If this doesn't work, contact your administrator to troubleshoot issues with your network.", 77 "expires_at": "2019-01-06T08:53:34.000000", 78 "id": "2076373e-13a7-4b84-9e67-15ce8cceaff8", 79 "created_at": "2018-12-07T08:53:34.000000", 80 "detail_id": "004", 81 "request_id": "req-957792ed-f38b-42db-a86a-850f815cbbe9", 82 "project_id": "a5e9d48232dc4aa59a716b5ced963584", 83 "resource_type": "SHARE", 84 "action_id": "002" 85 } 86 ] 87 }`) 88 }) 89 } 90 91 func MockGetResponse(t *testing.T) { 92 th.Mux.HandleFunc("/messages/2076373e-13a7-4b84-9e67-15ce8cceaff8", func(w http.ResponseWriter, r *http.Request) { 93 th.TestMethod(t, r, "GET") 94 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 95 96 w.Header().Add("Content-Type", "application/json") 97 w.WriteHeader(http.StatusOK) 98 fmt.Fprintf(w, ` 99 { 100 "message": { 101 "resource_id": "4336d74f-3bdc-4f27-9657-c01ec63680bf", 102 "message_level": "ERROR", 103 "user_message": "create: Could not find an existing share server or allocate one on the share network provided. You may use a different share network, or verify the network details in the share network and retry your request. If this doesn't work, contact your administrator to troubleshoot issues with your network.", 104 "expires_at": "2019-01-06T08:53:34.000000", 105 "id": "2076373e-13a7-4b84-9e67-15ce8cceaff8", 106 "created_at": "2018-12-07T08:53:34.000000", 107 "detail_id": "004", 108 "request_id": "req-957792ed-f38b-42db-a86a-850f815cbbe9", 109 "project_id": "a5e9d48232dc4aa59a716b5ced963584", 110 "resource_type": "SHARE", 111 "action_id": "002" 112 } 113 }`) 114 }) 115 }