forked from gophercloud/gophercloud
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request gophercloud#2811 from shiftstack/fixtures-internal
Make fixtures part of tests
- Loading branch information
Showing
187 changed files
with
526 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package testing | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
"testing" | ||
|
||
th "github.com/gophercloud/gophercloud/testhelper" | ||
fake "github.com/gophercloud/gophercloud/testhelper/client" | ||
) | ||
|
||
// HandleGetSuccessfully creates an HTTP handler at `/` on the test handler mux | ||
// that responds with a `Get` response. | ||
func HandleGetSuccessfully(t *testing.T) { | ||
th.Mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { | ||
th.TestMethod(t, r, "GET") | ||
th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) | ||
th.TestHeader(t, r, "Accept", "application/json") | ||
w.WriteHeader(http.StatusOK) | ||
fmt.Fprintf(w, ` | ||
{ | ||
"resources": { | ||
"rel/cdn": { | ||
"href-template": "services{?marker,limit}", | ||
"href-vars": { | ||
"marker": "param/marker", | ||
"limit": "param/limit" | ||
}, | ||
"hints": { | ||
"allow": [ | ||
"GET" | ||
], | ||
"formats": { | ||
"application/json": {} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
`) | ||
|
||
}) | ||
} | ||
|
||
// HandlePingSuccessfully creates an HTTP handler at `/ping` on the test handler | ||
// mux that responds with a `Ping` response. | ||
func HandlePingSuccessfully(t *testing.T) { | ||
th.Mux.HandleFunc("/ping", func(w http.ResponseWriter, r *http.Request) { | ||
th.TestMethod(t, r, "GET") | ||
th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) | ||
w.WriteHeader(http.StatusNoContent) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package testing | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
"testing" | ||
|
||
th "github.com/gophercloud/gophercloud/testhelper" | ||
fake "github.com/gophercloud/gophercloud/testhelper/client" | ||
) | ||
|
||
// HandleListCDNFlavorsSuccessfully creates an HTTP handler at `/flavors` on the test handler mux | ||
// that responds with a `List` response. | ||
func HandleListCDNFlavorsSuccessfully(t *testing.T) { | ||
th.Mux.HandleFunc("/flavors", func(w http.ResponseWriter, r *http.Request) { | ||
th.TestMethod(t, r, "GET") | ||
th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) | ||
|
||
w.Header().Set("Content-Type", "application/json") | ||
w.WriteHeader(http.StatusOK) | ||
fmt.Fprintf(w, ` | ||
{ | ||
"flavors": [ | ||
{ | ||
"id": "europe", | ||
"providers": [ | ||
{ | ||
"provider": "Fastly", | ||
"links": [ | ||
{ | ||
"href": "http://www.fastly.com", | ||
"rel": "provider_url" | ||
} | ||
] | ||
} | ||
], | ||
"links": [ | ||
{ | ||
"href": "https://www.poppycdn.io/v1.0/flavors/europe", | ||
"rel": "self" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
`) | ||
}) | ||
} | ||
|
||
// HandleGetCDNFlavorSuccessfully creates an HTTP handler at `/flavors/{id}` on the test handler mux | ||
// that responds with a `Get` response. | ||
func HandleGetCDNFlavorSuccessfully(t *testing.T) { | ||
th.Mux.HandleFunc("/flavors/asia", func(w http.ResponseWriter, r *http.Request) { | ||
th.TestMethod(t, r, "GET") | ||
th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) | ||
|
||
w.Header().Set("Content-Type", "application/json") | ||
w.WriteHeader(http.StatusOK) | ||
fmt.Fprintf(w, ` | ||
{ | ||
"id" : "asia", | ||
"providers" : [ | ||
{ | ||
"provider" : "ChinaCache", | ||
"links": [ | ||
{ | ||
"href": "http://www.chinacache.com", | ||
"rel": "provider_url" | ||
} | ||
] | ||
} | ||
], | ||
"links": [ | ||
{ | ||
"href": "https://www.poppycdn.io/v1.0/flavors/asia", | ||
"rel": "self" | ||
} | ||
] | ||
} | ||
`) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package testing | ||
|
||
import ( | ||
"net/http" | ||
"testing" | ||
|
||
th "github.com/gophercloud/gophercloud/testhelper" | ||
fake "github.com/gophercloud/gophercloud/testhelper/client" | ||
) | ||
|
||
// HandleDeleteCDNAssetSuccessfully creates an HTTP handler at `/services/{id}/assets` on the test handler mux | ||
// that responds with a `Delete` response. | ||
func HandleDeleteCDNAssetSuccessfully(t *testing.T) { | ||
th.Mux.HandleFunc("/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0/assets", func(w http.ResponseWriter, r *http.Request) { | ||
th.TestMethod(t, r, "DELETE") | ||
th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) | ||
w.WriteHeader(http.StatusAccepted) | ||
}) | ||
} |
Oops, something went wrong.