You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
818 B

  1. package cos
  2. import (
  3. "context"
  4. "encoding/xml"
  5. "fmt"
  6. "net/http"
  7. "reflect"
  8. "testing"
  9. )
  10. func TestBucketService_GetLocation(t *testing.T) {
  11. setup()
  12. defer teardown()
  13. mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
  14. testMethod(t, r, "GET")
  15. vs := values{
  16. "location": "",
  17. }
  18. testFormValues(t, r, vs)
  19. fmt.Fprint(w, `<?xml version='1.0' encoding='utf-8' ?>
  20. <LocationConstraint>ap-guangzhou</LocationConstraint>`)
  21. })
  22. ref, _, err := client.Bucket.GetLocation(context.Background())
  23. if err != nil {
  24. t.Fatalf("Bucket.GetLocation returned error: %v", err)
  25. }
  26. want := &BucketGetLocationResult{
  27. XMLName: xml.Name{Local: "LocationConstraint"},
  28. Location: "ap-guangzhou",
  29. }
  30. if !reflect.DeepEqual(ref, want) {
  31. t.Errorf("Bucket.GetLocation returned %+v, want %+v", ref, want)
  32. }
  33. }