@@ -19,13 +19,20 @@ const ExtraSpecsGetBody = `
1919}
2020`
2121
22- // ExtraSpecGetBody provides a GET result of a particular extra_spec for a flavor
22+ // GetExtraSpecBody provides a GET result of a particular extra_spec for a flavor
2323const GetExtraSpecBody = `
2424{
2525 "hw:cpu_policy": "CPU-POLICY"
2626}
2727`
2828
29+ // UpdatedExtraSpecBody provides an PUT result of a particular updated extra_spec for a flavor
30+ const UpdatedExtraSpecBody = `
31+ {
32+ "hw:cpu_policy": "CPU-POLICY-2"
33+ }
34+ `
35+
2936// ExtraSpecs is the expected extra_specs returned from GET on a flavor's extra_specs
3037var ExtraSpecs = map [string ]string {
3138 "hw:cpu_policy" : "CPU-POLICY" ,
@@ -37,6 +44,11 @@ var ExtraSpec = map[string]string{
3744 "hw:cpu_policy" : "CPU-POLICY" ,
3845}
3946
47+ // UpdatedExtraSpec is the expected extra_spec returned from PUT on a flavor's extra_specs
48+ var UpdatedExtraSpec = map [string ]string {
49+ "hw:cpu_policy" : "CPU-POLICY-2" ,
50+ }
51+
4052func HandleExtraSpecsListSuccessfully (t * testing.T ) {
4153 th .Mux .HandleFunc ("/flavors/1/os-extra_specs" , func (w http.ResponseWriter , r * http.Request ) {
4254 th .TestMethod (t , r , "GET" )
@@ -79,6 +91,21 @@ func HandleExtraSpecsCreateSuccessfully(t *testing.T) {
7991 })
8092}
8193
94+ func HandleExtraSpecUpdateSuccessfully (t * testing.T ) {
95+ th .Mux .HandleFunc ("/flavors/1/os-extra_specs/hw:cpu_policy" , func (w http.ResponseWriter , r * http.Request ) {
96+ th .TestMethod (t , r , "PUT" )
97+ th .TestHeader (t , r , "X-Auth-Token" , fake .TokenID )
98+ th .TestHeader (t , r , "Accept" , "application/json" )
99+ th .TestJSONRequest (t , r , `{
100+ "hw:cpu_policy": "CPU-POLICY-2"
101+ }` )
102+
103+ w .Header ().Set ("Content-Type" , "application/json" )
104+ w .WriteHeader (http .StatusOK )
105+ fmt .Fprintf (w , UpdatedExtraSpecBody )
106+ })
107+ }
108+
82109func HandleExtraSpecDeleteSuccessfully (t * testing.T ) {
83110 th .Mux .HandleFunc ("/flavors/1/os-extra_specs/hw:cpu_policy" , func (w http.ResponseWriter , r * http.Request ) {
84111 th .TestMethod (t , r , "DELETE" )
0 commit comments