Sanitize the package names
* All files in the same directory should belong to the same package * Avoid xyz/xyz_v123 format (example volume/volume_v2) * Added a doc.go so we can support a different import path later: https://golang.org/doc/go1.4#canonicalimports * Drop the trailing ".git" in the imports Change-Id: If4a880c62a2142f7015ed693e07af239bbbcf8e5
This commit is contained in:
parent
753e96dd4a
commit
ce3bd97613
2
Makefile
2
Makefile
@ -12,7 +12,7 @@ BASE_DIR := $(shell basename $(PWD))
|
|||||||
GOPATH_DEFAULT := $(PWD)/.go
|
GOPATH_DEFAULT := $(PWD)/.go
|
||||||
export GOPATH ?= $(GOPATH_DEFAULT)
|
export GOPATH ?= $(GOPATH_DEFAULT)
|
||||||
PKG := $(shell awk '/^package: / { print $$2 }' glide.yaml)
|
PKG := $(shell awk '/^package: / { print $$2 }' glide.yaml)
|
||||||
DEST := $(GOPATH)/src/$(GIT_HOST)/openstack/$(BASE_DIR).git
|
DEST := $(GOPATH)/src/$(GIT_HOST)/openstack/$(BASE_DIR)
|
||||||
DEST := $(GOPATH)/src/$(PKG)
|
DEST := $(GOPATH)/src/$(PKG)
|
||||||
|
|
||||||
# CTI targets
|
# CTI targets
|
||||||
|
@ -31,7 +31,7 @@ Code maturity is considered experimental.
|
|||||||
|
|
||||||
Installation
|
Installation
|
||||||
------------
|
------------
|
||||||
Use `go get git.openstack.org/openstack/golang-client.git`. Or alternatively,
|
Use `go get git.openstack.org/openstack/golang-client`. Or alternatively,
|
||||||
download or clone the repository.
|
download or clone the repository.
|
||||||
|
|
||||||
The lib was developed and tested on go 1.3. No external dependencies, so far.
|
The lib was developed and tested on go 1.3. No external dependencies, so far.
|
||||||
|
@ -18,10 +18,10 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
// "git.openstack.org/openstack/golang-client.git/identity/v2"
|
// "git.openstack.org/openstack/golang-client/identity/v2"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.openstack.org/openstack/golang-client.git/openstack"
|
"git.openstack.org/openstack/golang-client/openstack"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Authentication examples.
|
// Authentication examples.
|
||||||
|
@ -24,8 +24,8 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.openstack.org/openstack/golang-client.git/objectstorage/v1"
|
"git.openstack.org/openstack/golang-client/objectstorage/v1"
|
||||||
"git.openstack.org/openstack/golang-client.git/openstack"
|
"git.openstack.org/openstack/golang-client/openstack"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -21,8 +21,8 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.openstack.org/openstack/golang-client.git/image/v1"
|
"git.openstack.org/openstack/golang-client/image/v1"
|
||||||
"git.openstack.org/openstack/golang-client.git/openstack"
|
"git.openstack.org/openstack/golang-client/openstack"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Image examples.
|
// Image examples.
|
||||||
|
@ -21,8 +21,8 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.openstack.org/openstack/golang-client.git/openstack"
|
"git.openstack.org/openstack/golang-client/openstack"
|
||||||
"git.openstack.org/openstack/golang-client.git/volume/v2"
|
"git.openstack.org/openstack/golang-client/volume/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Volume examples.
|
// Volume examples.
|
||||||
|
@ -24,7 +24,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
|
||||||
"git.openstack.org/openstack/golang-client.git/openstack"
|
"git.openstack.org/openstack/golang-client/openstack"
|
||||||
)
|
)
|
||||||
|
|
||||||
// testconfig contains the user information needed by the acceptance and
|
// testconfig contains the user information needed by the acceptance and
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
package: git.openstack.org/openstack/golang-client.git
|
package: git.openstack.org/openstack/golang-client
|
||||||
import:
|
import:
|
||||||
- package: github.com/fullsailor/pkcs7
|
- package: github.com/fullsailor/pkcs7
|
||||||
|
@ -17,7 +17,7 @@ package middleware
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.openstack.org/openstack/golang-client.git/openstack"
|
"git.openstack.org/openstack/golang-client/openstack"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Validator struct {
|
type Validator struct {
|
||||||
|
@ -30,7 +30,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.openstack.org/openstack/golang-client.git/openstack"
|
"git.openstack.org/openstack/golang-client/openstack"
|
||||||
"github.com/fullsailor/pkcs7"
|
"github.com/fullsailor/pkcs7"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.openstack.org/openstack/golang-client.git/openstack"
|
"git.openstack.org/openstack/golang-client/openstack"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -20,7 +20,7 @@ Images and ImageDetails can be retrieved using the api.
|
|||||||
In addition more complex filtering and sort queries can by using the ImageQueryParameters.
|
In addition more complex filtering and sort queries can by using the ImageQueryParameters.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
package image
|
package v1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
@ -30,8 +30,8 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"git.openstack.org/openstack/golang-client.git/openstack"
|
"git.openstack.org/openstack/golang-client/openstack"
|
||||||
"git.openstack.org/openstack/golang-client.git/util"
|
"git.openstack.org/openstack/golang-client/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Service is a client service that can make
|
// Service is a client service that can make
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
|
|
||||||
// image.go
|
// image.go
|
||||||
package image_test
|
package v1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
@ -21,16 +21,15 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.openstack.org/openstack/golang-client.git/image/v1"
|
"git.openstack.org/openstack/golang-client/openstack"
|
||||||
"git.openstack.org/openstack/golang-client.git/openstack"
|
"git.openstack.org/openstack/golang-client/testUtil"
|
||||||
"git.openstack.org/openstack/golang-client.git/testUtil"
|
"git.openstack.org/openstack/golang-client/util"
|
||||||
"git.openstack.org/openstack/golang-client.git/util"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var tokn = "eaaafd18-0fed-4b3a-81b4-663c99ec1cbb"
|
var tokn = "eaaafd18-0fed-4b3a-81b4-663c99ec1cbb"
|
||||||
|
|
||||||
func TestListImages(t *testing.T) {
|
func TestListImages(t *testing.T) {
|
||||||
anon := func(imageService *image.Service) {
|
anon := func(imageService *Service) {
|
||||||
images, err := imageService.Images()
|
images, err := imageService.Images()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
@ -39,7 +38,7 @@ func TestListImages(t *testing.T) {
|
|||||||
if len(images) != 3 {
|
if len(images) != 3 {
|
||||||
t.Error(errors.New("Incorrect number of images found"))
|
t.Error(errors.New("Incorrect number of images found"))
|
||||||
}
|
}
|
||||||
expectedImage := image.Response{
|
expectedImage := Response{
|
||||||
Name: "Ubuntu Server 14.04.1 LTS (amd64 20140927) - Partner Image",
|
Name: "Ubuntu Server 14.04.1 LTS (amd64 20140927) - Partner Image",
|
||||||
ContainerFormat: "bare",
|
ContainerFormat: "bare",
|
||||||
DiskFormat: "qcow2",
|
DiskFormat: "qcow2",
|
||||||
@ -54,7 +53,7 @@ func TestListImages(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestListImageDetails(t *testing.T) {
|
func TestListImageDetails(t *testing.T) {
|
||||||
anon := func(imageService *image.Service) {
|
anon := func(imageService *Service) {
|
||||||
images, err := imageService.ImagesDetail()
|
images, err := imageService.ImagesDetail()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
@ -67,7 +66,7 @@ func TestListImageDetails(t *testing.T) {
|
|||||||
updatedAt, _ := util.NewDateTime(`"2014-09-29T15:33:37"`)
|
updatedAt, _ := util.NewDateTime(`"2014-09-29T15:33:37"`)
|
||||||
owner := "10014302369510"
|
owner := "10014302369510"
|
||||||
virtualSize := int64(2525125)
|
virtualSize := int64(2525125)
|
||||||
expectedImageDetail := image.DetailResponse{
|
expectedImageDetail := DetailResponse{
|
||||||
Status: "active",
|
Status: "active",
|
||||||
Name: "Ubuntu Server 12.04.5 LTS (amd64 20140927) - Partner Image",
|
Name: "Ubuntu Server 12.04.5 LTS (amd64 20140927) - Partner Image",
|
||||||
Deleted: false,
|
Deleted: false,
|
||||||
@ -109,48 +108,48 @@ func TestListImageDetails(t *testing.T) {
|
|||||||
|
|
||||||
func TestNameFilterUrlProduced(t *testing.T) {
|
func TestNameFilterUrlProduced(t *testing.T) {
|
||||||
testImageQueryParameter(t, "images?name=CentOS+deprecated",
|
testImageQueryParameter(t, "images?name=CentOS+deprecated",
|
||||||
image.QueryParameters{Name: "CentOS deprecated"})
|
QueryParameters{Name: "CentOS deprecated"})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStatusUrlProduced(t *testing.T) {
|
func TestStatusUrlProduced(t *testing.T) {
|
||||||
testImageQueryParameter(t, "images?status=active",
|
testImageQueryParameter(t, "images?status=active",
|
||||||
image.QueryParameters{Status: "active"})
|
QueryParameters{Status: "active"})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMinMaxSizeUrlProduced(t *testing.T) {
|
func TestMinMaxSizeUrlProduced(t *testing.T) {
|
||||||
testImageQueryParameter(t, "images?size_max=5300014&size_min=100158",
|
testImageQueryParameter(t, "images?size_max=5300014&size_min=100158",
|
||||||
image.QueryParameters{MinSize: 100158, MaxSize: 5300014})
|
QueryParameters{MinSize: 100158, MaxSize: 5300014})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMarkerLimitUrlProduced(t *testing.T) {
|
func TestMarkerLimitUrlProduced(t *testing.T) {
|
||||||
testImageQueryParameter(t, "images?limit=20&marker=bec3cab5-4722-40b9-a78a-3489218e22fe",
|
testImageQueryParameter(t, "images?limit=20&marker=bec3cab5-4722-40b9-a78a-3489218e22fe",
|
||||||
image.QueryParameters{Marker: "bec3cab5-4722-40b9-a78a-3489218e22fe", Limit: 20})
|
QueryParameters{Marker: "bec3cab5-4722-40b9-a78a-3489218e22fe", Limit: 20})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestContainerFormatFilterUrlProduced(t *testing.T) {
|
func TestContainerFormatFilterUrlProduced(t *testing.T) {
|
||||||
testImageQueryParameter(t, "images?container_format=bare",
|
testImageQueryParameter(t, "images?container_format=bare",
|
||||||
image.QueryParameters{ContainerFormat: "bare"})
|
QueryParameters{ContainerFormat: "bare"})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSortKeySortUrlProduced(t *testing.T) {
|
func TestSortKeySortUrlProduced(t *testing.T) {
|
||||||
testImageQueryParameter(t, "images?sort_key=id",
|
testImageQueryParameter(t, "images?sort_key=id",
|
||||||
image.QueryParameters{SortKey: "id"})
|
QueryParameters{SortKey: "id"})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSortDirSortUrlProduced(t *testing.T) {
|
func TestSortDirSortUrlProduced(t *testing.T) {
|
||||||
testImageQueryParameter(t, "images?sort_dir=asc",
|
testImageQueryParameter(t, "images?sort_dir=asc",
|
||||||
image.QueryParameters{SortDirection: image.Asc})
|
QueryParameters{SortDirection: Asc})
|
||||||
}
|
}
|
||||||
|
|
||||||
func testImageQueryParameter(t *testing.T, uriEndsWith string, queryParameters image.QueryParameters) {
|
func testImageQueryParameter(t *testing.T, uriEndsWith string, queryParameters QueryParameters) {
|
||||||
anon := func(imageService *image.Service) {
|
anon := func(imageService *Service) {
|
||||||
_, _ = imageService.QueryImages(&queryParameters)
|
_, _ = imageService.QueryImages(&queryParameters)
|
||||||
}
|
}
|
||||||
|
|
||||||
testImageServiceAction(t, uriEndsWith, sampleImagesData, anon)
|
testImageServiceAction(t, uriEndsWith, sampleImagesData, anon)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testImageServiceAction(t *testing.T, uriEndsWith string, testData string, imageServiceAction func(*image.Service)) {
|
func testImageServiceAction(t *testing.T, uriEndsWith string, testData string, imageServiceAction func(*Service)) {
|
||||||
anon := func(req *http.Request) {
|
anon := func(req *http.Request) {
|
||||||
reqURL := req.URL.String()
|
reqURL := req.URL.String()
|
||||||
if !strings.HasSuffix(reqURL, uriEndsWith) {
|
if !strings.HasSuffix(reqURL, uriEndsWith) {
|
||||||
@ -168,7 +167,7 @@ func testImageServiceAction(t *testing.T, uriEndsWith string, testData string, i
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
sess, _ := openstack.NewSession(http.DefaultClient, auth, nil)
|
sess, _ := openstack.NewSession(http.DefaultClient, auth, nil)
|
||||||
imageService := image.Service{
|
imageService := Service{
|
||||||
Session: *sess,
|
Session: *sess,
|
||||||
URL: apiServer.URL,
|
URL: apiServer.URL,
|
||||||
}
|
}
|
||||||
|
@ -20,8 +20,8 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"git.openstack.org/openstack/golang-client.git/openstack"
|
"git.openstack.org/openstack/golang-client/openstack"
|
||||||
"git.openstack.org/openstack/golang-client.git/util"
|
"git.openstack.org/openstack/golang-client/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
var zeroByte = &([]byte{}) //pointer to empty []byte
|
var zeroByte = &([]byte{}) //pointer to empty []byte
|
||||||
|
@ -12,12 +12,11 @@
|
|||||||
// License for the specific language governing permissions and limitations
|
// License for the specific language governing permissions and limitations
|
||||||
// under the License.
|
// under the License.
|
||||||
|
|
||||||
package objectstorage_test
|
package objectstorage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"git.openstack.org/openstack/golang-client.git/objectstorage/v1"
|
"git.openstack.org/openstack/golang-client/openstack"
|
||||||
"git.openstack.org/openstack/golang-client.git/openstack"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
@ -49,7 +48,7 @@ func TestGetAccountMeta(t *testing.T) {
|
|||||||
defer apiServer.Close()
|
defer apiServer.Close()
|
||||||
|
|
||||||
sess := testGetSession()
|
sess := testGetSession()
|
||||||
meta, err := objectstorage.GetAccountMeta(sess, apiServer.URL)
|
meta, err := GetAccountMeta(sess, apiServer.URL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
@ -80,7 +79,7 @@ func TestListContainers(t *testing.T) {
|
|||||||
defer apiServer.Close()
|
defer apiServer.Close()
|
||||||
|
|
||||||
sess := testGetSession()
|
sess := testGetSession()
|
||||||
myList, err := objectstorage.ListContainers(sess, 0, "", apiServer.URL)
|
myList, err := ListContainers(sess, 0, "", apiServer.URL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
@ -115,7 +114,7 @@ func TestListObjects(t *testing.T) {
|
|||||||
defer apiServer.Close()
|
defer apiServer.Close()
|
||||||
|
|
||||||
sess := testGetSession()
|
sess := testGetSession()
|
||||||
myList, err := objectstorage.ListObjects(
|
myList, err := ListObjects(
|
||||||
sess, 0, "", "", "", "", apiServer.URL+containerPrefix)
|
sess, 0, "", "", "", "", apiServer.URL+containerPrefix)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
@ -137,7 +136,7 @@ func TestDeleteContainer(t *testing.T) {
|
|||||||
defer apiServer.Close()
|
defer apiServer.Close()
|
||||||
|
|
||||||
sess := testGetSession()
|
sess := testGetSession()
|
||||||
if err := objectstorage.DeleteContainer(sess, apiServer.URL+containerPrefix); err != nil {
|
if err := DeleteContainer(sess, apiServer.URL+containerPrefix); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -157,7 +156,7 @@ func TestGetContainerMeta(t *testing.T) {
|
|||||||
defer apiServer.Close()
|
defer apiServer.Close()
|
||||||
|
|
||||||
sess := testGetSession()
|
sess := testGetSession()
|
||||||
meta, err := objectstorage.GetContainerMeta(sess, apiServer.URL+containerPrefix)
|
meta, err := GetContainerMeta(sess, apiServer.URL+containerPrefix)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
@ -183,7 +182,7 @@ func TestSetContainerMeta(t *testing.T) {
|
|||||||
sess := testGetSession()
|
sess := testGetSession()
|
||||||
headers := http.Header{}
|
headers := http.Header{}
|
||||||
headers.Add("X-Container-Meta-Fruit", "Apple")
|
headers.Add("X-Container-Meta-Fruit", "Apple")
|
||||||
if err := objectstorage.SetContainerMeta(
|
if err := SetContainerMeta(
|
||||||
sess, apiServer.URL+containerPrefix,
|
sess, apiServer.URL+containerPrefix,
|
||||||
headers); err != nil {
|
headers); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
@ -205,7 +204,7 @@ func TestPutContainer(t *testing.T) {
|
|||||||
headers := http.Header{}
|
headers := http.Header{}
|
||||||
headers.Add("X-TTL", "259200")
|
headers.Add("X-TTL", "259200")
|
||||||
headers.Add("X-Log-Retention", "true")
|
headers.Add("X-Log-Retention", "true")
|
||||||
if err := objectstorage.PutContainer(sess, apiServer.URL+containerPrefix,
|
if err := PutContainer(sess, apiServer.URL+containerPrefix,
|
||||||
headers); err != nil {
|
headers); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
@ -239,7 +238,7 @@ func TestPutObject(t *testing.T) {
|
|||||||
|
|
||||||
sess := testGetSession()
|
sess := testGetSession()
|
||||||
headers := http.Header{}
|
headers := http.Header{}
|
||||||
if err = objectstorage.PutObject(sess, &fContent, apiServer.URL+objPrefix, headers); err != nil {
|
if err = PutObject(sess, &fContent, apiServer.URL+objPrefix, headers); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -258,7 +257,7 @@ func TestCopyObject(t *testing.T) {
|
|||||||
defer apiServer.Close()
|
defer apiServer.Close()
|
||||||
|
|
||||||
sess := testGetSession()
|
sess := testGetSession()
|
||||||
if err := objectstorage.CopyObject(sess, apiServer.URL+objPrefix, destURL); err != nil {
|
if err := CopyObject(sess, apiServer.URL+objPrefix, destURL); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -278,7 +277,7 @@ func TestGetObjectMeta(t *testing.T) {
|
|||||||
defer apiServer.Close()
|
defer apiServer.Close()
|
||||||
|
|
||||||
sess := testGetSession()
|
sess := testGetSession()
|
||||||
meta, err := objectstorage.GetObjectMeta(sess, apiServer.URL+objPrefix)
|
meta, err := GetObjectMeta(sess, apiServer.URL+objPrefix)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
@ -302,7 +301,7 @@ func TestSetObjectMeta(t *testing.T) {
|
|||||||
sess := testGetSession()
|
sess := testGetSession()
|
||||||
headers := http.Header{}
|
headers := http.Header{}
|
||||||
headers.Add("X-Object-Meta-Fruit", "Apple")
|
headers.Add("X-Object-Meta-Fruit", "Apple")
|
||||||
if err := objectstorage.SetObjectMeta(sess, apiServer.URL+objPrefix,
|
if err := SetObjectMeta(sess, apiServer.URL+objPrefix,
|
||||||
headers); err != nil {
|
headers); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
@ -329,7 +328,7 @@ func TestGetObject(t *testing.T) {
|
|||||||
defer apiServer.Close()
|
defer apiServer.Close()
|
||||||
|
|
||||||
sess := testGetSession()
|
sess := testGetSession()
|
||||||
hdr, body, err := objectstorage.GetObject(sess, apiServer.URL+objPrefix)
|
hdr, body, err := GetObject(sess, apiServer.URL+objPrefix)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
@ -356,7 +355,7 @@ func TestDeleteObject(t *testing.T) {
|
|||||||
defer apiServer.Close()
|
defer apiServer.Close()
|
||||||
|
|
||||||
sess := testGetSession()
|
sess := testGetSession()
|
||||||
if err := objectstorage.DeleteObject(sess, apiServer.URL+objPrefix); err != nil {
|
if err := DeleteObject(sess, apiServer.URL+objPrefix); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ import (
|
|||||||
"net/http/httputil"
|
"net/http/httputil"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"git.openstack.org/openstack/golang-client.git/util"
|
"git.openstack.org/openstack/golang-client/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Debug = new(bool)
|
var Debug = new(bool)
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package openstack_test
|
package openstack
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
@ -21,8 +21,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.openstack.org/openstack/golang-client.git/openstack"
|
"git.openstack.org/openstack/golang-client/testUtil"
|
||||||
"git.openstack.org/openstack/golang-client.git/testUtil"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type TestStruct struct {
|
type TestStruct struct {
|
||||||
@ -41,7 +40,7 @@ func TestSessionGet(t *testing.T) {
|
|||||||
expected := TestStruct{ID: "id1", Name: "Chris"}
|
expected := TestStruct{ID: "id1", Name: "Chris"}
|
||||||
actual := TestStruct{}
|
actual := TestStruct{}
|
||||||
|
|
||||||
s, _ := openstack.NewSession(nil, nil, nil)
|
s, _ := NewSession(nil, nil, nil)
|
||||||
var headers http.Header = http.Header{}
|
var headers http.Header = http.Header{}
|
||||||
headers.Set("X-Auth-Token", tokn)
|
headers.Set("X-Auth-Token", tokn)
|
||||||
headers.Set("Accept", "application/json")
|
headers.Set("Accept", "application/json")
|
||||||
|
@ -12,20 +12,19 @@
|
|||||||
// License for the specific language governing permissions and limitations
|
// License for the specific language governing permissions and limitations
|
||||||
// under the License.
|
// under the License.
|
||||||
|
|
||||||
package util_test
|
package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.openstack.org/openstack/golang-client.git/testUtil"
|
"git.openstack.org/openstack/golang-client/testUtil"
|
||||||
"git.openstack.org/openstack/golang-client.git/util"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var testValue = `{"created_at":"2014-09-29T14:44:31"}`
|
var testValue = `{"created_at":"2014-09-29T14:44:31"}`
|
||||||
var testTime, _ = time.Parse(`"2006-01-02T15:04:05"`, `"2014-09-29T14:44:31"`)
|
var testTime, _ = time.Parse(`"2006-01-02T15:04:05"`, `"2014-09-29T14:44:31"`)
|
||||||
var timeTestValue = timeTest{CreatedAt: util.RFC8601DateTime{testTime}}
|
var timeTestValue = timeTest{CreatedAt: RFC8601DateTime{testTime}}
|
||||||
|
|
||||||
func TestMarshalTimeTest(t *testing.T) {
|
func TestMarshalTimeTest(t *testing.T) {
|
||||||
bytes, _ := json.Marshal(timeTestValue)
|
bytes, _ := json.Marshal(timeTestValue)
|
||||||
@ -55,5 +54,5 @@ func TestUnmarshalInvalidDateTimeFormatTimeTest(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type timeTest struct {
|
type timeTest struct {
|
||||||
CreatedAt util.RFC8601DateTime `json:"created_at"`
|
CreatedAt RFC8601DateTime `json:"created_at"`
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
// License for the specific language governing permissions and limitations
|
// License for the specific language governing permissions and limitations
|
||||||
// under the License.
|
// under the License.
|
||||||
|
|
||||||
package util_test
|
package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
@ -23,8 +23,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.openstack.org/openstack/golang-client.git/testUtil"
|
"git.openstack.org/openstack/golang-client/testUtil"
|
||||||
"git.openstack.org/openstack/golang-client.git/util"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var token = "2350971-5716-8165"
|
var token = "2350971-5716-8165"
|
||||||
@ -33,7 +32,7 @@ func TestDelete(t *testing.T) {
|
|||||||
var apiServer = testUtil.CreateDeleteTestRequestServer(t, token, "/other")
|
var apiServer = testUtil.CreateDeleteTestRequestServer(t, token, "/other")
|
||||||
defer apiServer.Close()
|
defer apiServer.Close()
|
||||||
|
|
||||||
err := util.Delete(apiServer.URL+"/other", token, *http.DefaultClient)
|
err := Delete(apiServer.URL+"/other", token, *http.DefaultClient)
|
||||||
testUtil.IsNil(t, err)
|
testUtil.IsNil(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +42,7 @@ func TestPostJsonWithValidResponse(t *testing.T) {
|
|||||||
actual := TestStruct{}
|
actual := TestStruct{}
|
||||||
ti := TestStruct{ID: "id1", Name: "name"}
|
ti := TestStruct{ID: "id1", Name: "name"}
|
||||||
|
|
||||||
err := util.PostJSON(apiServer.URL, token, *http.DefaultClient, ti, &actual)
|
err := PostJSON(apiServer.URL, token, *http.DefaultClient, ti, &actual)
|
||||||
testUtil.IsNil(t, err)
|
testUtil.IsNil(t, err)
|
||||||
expected := TestStruct{ID: "id1", Name: "Chris"}
|
expected := TestStruct{ID: "id1", Name: "Chris"}
|
||||||
|
|
||||||
@ -60,13 +59,13 @@ func TestCallAPI(t *testing.T) {
|
|||||||
w.WriteHeader(200) //ok
|
w.WriteHeader(200) //ok
|
||||||
}))
|
}))
|
||||||
zeroByte := &([]byte{})
|
zeroByte := &([]byte{})
|
||||||
if _, err := util.CallAPI("HEAD", apiServer.URL, zeroByte, "X-Auth-Token", tokn); err != nil {
|
if _, err := CallAPI("HEAD", apiServer.URL, zeroByte, "X-Auth-Token", tokn); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
if _, err := util.CallAPI("DELETE", apiServer.URL, zeroByte, "X-Auth-Token", tokn); err != nil {
|
if _, err := CallAPI("DELETE", apiServer.URL, zeroByte, "X-Auth-Token", tokn); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
if _, err := util.CallAPI("POST", apiServer.URL, zeroByte, "X-Auth-Token", tokn); err != nil {
|
if _, err := CallAPI("POST", apiServer.URL, zeroByte, "X-Auth-Token", tokn); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -90,7 +89,7 @@ func TestCallAPIGetContent(t *testing.T) {
|
|||||||
w.Write(body)
|
w.Write(body)
|
||||||
}))
|
}))
|
||||||
var resp *http.Response
|
var resp *http.Response
|
||||||
if resp, err = util.CallAPI("GET", apiServer.URL, &fContent, "X-Auth-Token", tokn,
|
if resp, err = CallAPI("GET", apiServer.URL, &fContent, "X-Auth-Token", tokn,
|
||||||
"Etag", "md5hash-blahblah"); err != nil {
|
"Etag", "md5hash-blahblah"); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
@ -129,7 +128,7 @@ func TestCallAPIPutContent(t *testing.T) {
|
|||||||
}
|
}
|
||||||
w.WriteHeader(200)
|
w.WriteHeader(200)
|
||||||
}))
|
}))
|
||||||
if _, err = util.CallAPI("PUT", apiServer.URL, &fContent, "X-Auth-Token", tokn); err != nil {
|
if _, err = CallAPI("PUT", apiServer.URL, &fContent, "X-Auth-Token", tokn); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ Volumes and VolumeDetails can be retrieved using the api.
|
|||||||
In addition more complex filtering and sort queries can by using the VolumeQueryParameters.
|
In addition more complex filtering and sort queries can by using the VolumeQueryParameters.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
package volume_v2
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
@ -30,8 +30,8 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"git.openstack.org/openstack/golang-client.git/openstack"
|
"git.openstack.org/openstack/golang-client/openstack"
|
||||||
"git.openstack.org/openstack/golang-client.git/util"
|
"git.openstack.org/openstack/golang-client/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Service is a client service that can make
|
// Service is a client service that can make
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
|
|
||||||
// volume.go
|
// volume.go
|
||||||
package volume_v2_test
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
@ -21,16 +21,15 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.openstack.org/openstack/golang-client.git/openstack"
|
"git.openstack.org/openstack/golang-client/openstack"
|
||||||
"git.openstack.org/openstack/golang-client.git/testUtil"
|
"git.openstack.org/openstack/golang-client/testUtil"
|
||||||
"git.openstack.org/openstack/golang-client.git/util"
|
"git.openstack.org/openstack/golang-client/util"
|
||||||
"git.openstack.org/openstack/golang-client.git/volume/v2"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var tokn = "ae5aebe5-6a5d-4a40-840a-9736a067aff4"
|
var tokn = "ae5aebe5-6a5d-4a40-840a-9736a067aff4"
|
||||||
|
|
||||||
func TestListVolumes(t *testing.T) {
|
func TestListVolumes(t *testing.T) {
|
||||||
anon := func(volumeService *volume_v2.Service) {
|
anon := func(volumeService *Service) {
|
||||||
volumes, err := volumeService.Volumes()
|
volumes, err := volumeService.Volumes()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
@ -39,7 +38,7 @@ func TestListVolumes(t *testing.T) {
|
|||||||
if len(volumes) != 2 {
|
if len(volumes) != 2 {
|
||||||
t.Error(errors.New("Incorrect number of volumes found"))
|
t.Error(errors.New("Incorrect number of volumes found"))
|
||||||
}
|
}
|
||||||
expectedVolume := volume_v2.Response{
|
expectedVolume := Response{
|
||||||
Name: "volume_test1",
|
Name: "volume_test1",
|
||||||
ID: "f5fc9874-fc89-4814-a358-23ba83a6115f",
|
ID: "f5fc9874-fc89-4814-a358-23ba83a6115f",
|
||||||
Links: []map[string]string{{"href": "http://172.16.197.131:8776/v2/1d8837c5fcef4892951397df97661f97/volumes/f5fc9874-fc89-4814-a358-23ba83a6115f", "rel": "self"},
|
Links: []map[string]string{{"href": "http://172.16.197.131:8776/v2/1d8837c5fcef4892951397df97661f97/volumes/f5fc9874-fc89-4814-a358-23ba83a6115f", "rel": "self"},
|
||||||
@ -52,7 +51,7 @@ func TestListVolumes(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestListVolumeDetails(t *testing.T) {
|
func TestListVolumeDetails(t *testing.T) {
|
||||||
anon := func(volumeService *volume_v2.Service) {
|
anon := func(volumeService *Service) {
|
||||||
volumes, err := volumeService.VolumesDetail()
|
volumes, err := volumeService.VolumesDetail()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
@ -62,7 +61,7 @@ func TestListVolumeDetails(t *testing.T) {
|
|||||||
t.Error(errors.New("Incorrect number of volumes found"))
|
t.Error(errors.New("Incorrect number of volumes found"))
|
||||||
}
|
}
|
||||||
createdAt, _ := util.NewDateTime(`"2014-09-29T14:44:31"`)
|
createdAt, _ := util.NewDateTime(`"2014-09-29T14:44:31"`)
|
||||||
expectedVolumeDetail := volume_v2.DetailResponse{
|
expectedVolumeDetail := DetailResponse{
|
||||||
ID: "30becf77-63fe-4f5e-9507-a0578ffe0949",
|
ID: "30becf77-63fe-4f5e-9507-a0578ffe0949",
|
||||||
Attachments: []map[string]string{{"attachment_id": "ddb2ac07-ed62-49eb-93da-73b258dd9bec", "host_name": "host_test", "volume_id": "30becf77-63fe-4f5e-9507-a0578ffe0949", "device": "/dev/vdb", "id": "30becf77-63fe-4f5e-9507-a0578ffe0949", "server_id": "0f081aae-1b0c-4b89-930c-5f2562460c72"}},
|
Attachments: []map[string]string{{"attachment_id": "ddb2ac07-ed62-49eb-93da-73b258dd9bec", "host_name": "host_test", "volume_id": "30becf77-63fe-4f5e-9507-a0578ffe0949", "device": "/dev/vdb", "id": "30becf77-63fe-4f5e-9507-a0578ffe0949", "server_id": "0f081aae-1b0c-4b89-930c-5f2562460c72"}},
|
||||||
Links: []map[string]string{{"href": "http://172.16.197.131:8776/v2/1d8837c5fcef4892951397df97661f97/volumes/30becf77-63fe-4f5e-9507-a0578ffe0949", "rel": "self"},
|
Links: []map[string]string{{"href": "http://172.16.197.131:8776/v2/1d8837c5fcef4892951397df97661f97/volumes/30becf77-63fe-4f5e-9507-a0578ffe0949", "rel": "self"},
|
||||||
@ -93,38 +92,38 @@ func TestListVolumeDetails(t *testing.T) {
|
|||||||
|
|
||||||
func TestLimitFilterUrlProduced(t *testing.T) {
|
func TestLimitFilterUrlProduced(t *testing.T) {
|
||||||
testVolumeQueryParameter(t, "volumes?limit=2",
|
testVolumeQueryParameter(t, "volumes?limit=2",
|
||||||
volume_v2.QueryParameters{Limit: 2})
|
QueryParameters{Limit: 2})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAll_tenantFilterUrlProduced(t *testing.T) {
|
func TestAll_tenantFilterUrlProduced(t *testing.T) {
|
||||||
testVolumeQueryParameter(t, "volumes?all_tenant=1",
|
testVolumeQueryParameter(t, "volumes?all_tenant=1",
|
||||||
volume_v2.QueryParameters{All_tenant: 1})
|
QueryParameters{All_tenant: 1})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMarkerUrlProduced(t *testing.T) {
|
func TestMarkerUrlProduced(t *testing.T) {
|
||||||
testVolumeQueryParameter(t, "volumes?marker=1776335d-72f1-48c9-b0e7-74c62cb8fede",
|
testVolumeQueryParameter(t, "volumes?marker=1776335d-72f1-48c9-b0e7-74c62cb8fede",
|
||||||
volume_v2.QueryParameters{Marker: "1776335d-72f1-48c9-b0e7-74c62cb8fede"})
|
QueryParameters{Marker: "1776335d-72f1-48c9-b0e7-74c62cb8fede"})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSortKeySortUrlProduced(t *testing.T) {
|
func TestSortKeySortUrlProduced(t *testing.T) {
|
||||||
testVolumeQueryParameter(t, "volumes?sort_key=id",
|
testVolumeQueryParameter(t, "volumes?sort_key=id",
|
||||||
volume_v2.QueryParameters{SortKey: "id"})
|
QueryParameters{SortKey: "id"})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSortDirSortUrlProduced(t *testing.T) {
|
func TestSortDirSortUrlProduced(t *testing.T) {
|
||||||
testVolumeQueryParameter(t, "volumes?sort_dir=asc",
|
testVolumeQueryParameter(t, "volumes?sort_dir=asc",
|
||||||
volume_v2.QueryParameters{SortDirection: volume_v2.Asc})
|
QueryParameters{SortDirection: Asc})
|
||||||
}
|
}
|
||||||
|
|
||||||
func testVolumeQueryParameter(t *testing.T, uriEndsWith string, queryParameters volume_v2.QueryParameters) {
|
func testVolumeQueryParameter(t *testing.T, uriEndsWith string, queryParameters QueryParameters) {
|
||||||
anon := func(volumeService *volume_v2.Service) {
|
anon := func(volumeService *Service) {
|
||||||
_, _ = volumeService.QueryVolumes(&queryParameters)
|
_, _ = volumeService.QueryVolumes(&queryParameters)
|
||||||
}
|
}
|
||||||
|
|
||||||
testVolumeServiceAction(t, uriEndsWith, sampleVolumesData, anon)
|
testVolumeServiceAction(t, uriEndsWith, sampleVolumesData, anon)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testVolumeServiceAction(t *testing.T, uriEndsWith string, testData string, volumeServiceAction func(*volume_v2.Service)) {
|
func testVolumeServiceAction(t *testing.T, uriEndsWith string, testData string, volumeServiceAction func(*Service)) {
|
||||||
anon := func(req *http.Request) {
|
anon := func(req *http.Request) {
|
||||||
reqURL := req.URL.String()
|
reqURL := req.URL.String()
|
||||||
if !strings.HasSuffix(reqURL, uriEndsWith) {
|
if !strings.HasSuffix(reqURL, uriEndsWith) {
|
||||||
@ -142,7 +141,7 @@ func testVolumeServiceAction(t *testing.T, uriEndsWith string, testData string,
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
sess, _ := openstack.NewSession(http.DefaultClient, auth, nil)
|
sess, _ := openstack.NewSession(http.DefaultClient, auth, nil)
|
||||||
volumeService := volume_v2.Service{
|
volumeService := Service{
|
||||||
Session: *sess,
|
Session: *sess,
|
||||||
URL: apiServer.URL,
|
URL: apiServer.URL,
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ Show and List methods can work.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package volume_v3
|
package v3
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
@ -30,8 +30,8 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"git.openstack.org/openstack/golang-client.git/openstack"
|
"git.openstack.org/openstack/golang-client/openstack"
|
||||||
"git.openstack.org/openstack/golang-client.git/util"
|
"git.openstack.org/openstack/golang-client/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Service struct {
|
type Service struct {
|
||||||
|
@ -19,7 +19,7 @@ The CRUD operation of volumes can be retrieved using the api.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package volume_v3_test
|
package v3
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
@ -27,9 +27,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.openstack.org/openstack/golang-client.git/openstack"
|
"git.openstack.org/openstack/golang-client/openstack"
|
||||||
"git.openstack.org/openstack/golang-client.git/testUtil"
|
"git.openstack.org/openstack/golang-client/testUtil"
|
||||||
"git.openstack.org/openstack/golang-client.git/volume/v3"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var tokn = "ae5aebe5-6a5d-4a40-840a-9736a067aff4"
|
var tokn = "ae5aebe5-6a5d-4a40-840a-9736a067aff4"
|
||||||
@ -57,14 +56,14 @@ func TestCreateVolume(t *testing.T) {
|
|||||||
|
|
||||||
// TODO(dtroyer): skipping due to job failure for now, this must be fixed
|
// TODO(dtroyer): skipping due to job failure for now, this must be fixed
|
||||||
// func TestGetVolume(t *testing.T) {
|
// func TestGetVolume(t *testing.T) {
|
||||||
// anon := func(volumeService *volume_v3.Service) {
|
// anon := func(volumeService *Service) {
|
||||||
// volID := "f5fc9874-fc89-4814-a358-23ba83a6115f"
|
// volID := "f5fc9874-fc89-4814-a358-23ba83a6115f"
|
||||||
// volume, err := volumeService.Show(volID)
|
// volume, err := volumeService.Show(volID)
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// t.Error(err)
|
// t.Error(err)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// expectedVolume := volume_v3.Response{
|
// expectedVolume := Response{
|
||||||
// Name: "myvol1",
|
// Name: "myvol1",
|
||||||
// ID: "f5fc9874-fc89-4814-a358-23ba83a6115f",
|
// ID: "f5fc9874-fc89-4814-a358-23ba83a6115f",
|
||||||
// // Links: []map[string]string{{"href": "http://172.16.197.131:8776/v2/1d8837c5fcef4892951397df97661f97/volumes/f5fc9874-fc89-4814-a358-23ba83a6115f", "rel": "self"},
|
// // Links: []map[string]string{{"href": "http://172.16.197.131:8776/v2/1d8837c5fcef4892951397df97661f97/volumes/f5fc9874-fc89-4814-a358-23ba83a6115f", "rel": "self"},
|
||||||
@ -76,7 +75,7 @@ func TestCreateVolume(t *testing.T) {
|
|||||||
// testGetVolumeServiceAction(t, "f5fc9874-fc89-4814-a358-23ba83a6115f", sampleVolumeData, anon)
|
// testGetVolumeServiceAction(t, "f5fc9874-fc89-4814-a358-23ba83a6115f", sampleVolumeData, anon)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
func testGetVolumeServiceAction(t *testing.T, uriEndsWith string, testData string, volumeServiceAction func(*volume_v3.Service)) {
|
func testGetVolumeServiceAction(t *testing.T, uriEndsWith string, testData string, volumeServiceAction func(*Service)) {
|
||||||
anon := func(req *http.Request) {
|
anon := func(req *http.Request) {
|
||||||
reqURL := req.URL.String()
|
reqURL := req.URL.String()
|
||||||
if !strings.HasSuffix(reqURL, uriEndsWith) {
|
if !strings.HasSuffix(reqURL, uriEndsWith) {
|
||||||
@ -94,7 +93,7 @@ func testGetVolumeServiceAction(t *testing.T, uriEndsWith string, testData strin
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
sess, _ := openstack.NewSession(http.DefaultClient, auth, nil)
|
sess, _ := openstack.NewSession(http.DefaultClient, auth, nil)
|
||||||
volumeService := volume_v3.Service{
|
volumeService := Service{
|
||||||
Session: *sess,
|
Session: *sess,
|
||||||
URL: apiServer.URL,
|
URL: apiServer.URL,
|
||||||
}
|
}
|
||||||
@ -102,13 +101,13 @@ func testGetVolumeServiceAction(t *testing.T, uriEndsWith string, testData strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetAllVolumes(t *testing.T) {
|
func TestGetAllVolumes(t *testing.T) {
|
||||||
anon := func(volumeService *volume_v3.Service) {
|
anon := func(volumeService *Service) {
|
||||||
volumes, err := volumeService.List()
|
volumes, err := volumeService.List()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
expectedVolume := volume_v3.Response{
|
expectedVolume := Response{
|
||||||
Name: "myvol1",
|
Name: "myvol1",
|
||||||
ID: "f5fc9874-fc89-4814-a358-23ba83a6115f",
|
ID: "f5fc9874-fc89-4814-a358-23ba83a6115f",
|
||||||
// Links: []map[string]string{{"href": "http://172.16.197.131:8776/v2/1d8837c5fcef4892951397df97661f97/volumes/f5fc9874-fc89-4814-a358-23ba83a6115f", "rel": "self"},
|
// Links: []map[string]string{{"href": "http://172.16.197.131:8776/v2/1d8837c5fcef4892951397df97661f97/volumes/f5fc9874-fc89-4814-a358-23ba83a6115f", "rel": "self"},
|
||||||
@ -120,7 +119,7 @@ func TestGetAllVolumes(t *testing.T) {
|
|||||||
testGetAllVolumesServiceAction(t, "volumes", sampleVolumesData, anon)
|
testGetAllVolumesServiceAction(t, "volumes", sampleVolumesData, anon)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testGetAllVolumesServiceAction(t *testing.T, uriEndsWith string, testData string, volumeServiceAction func(*volume_v3.Service)) {
|
func testGetAllVolumesServiceAction(t *testing.T, uriEndsWith string, testData string, volumeServiceAction func(*Service)) {
|
||||||
anon := func(req *http.Request) {
|
anon := func(req *http.Request) {
|
||||||
reqURL := req.URL.String()
|
reqURL := req.URL.String()
|
||||||
if !strings.HasSuffix(reqURL, uriEndsWith) {
|
if !strings.HasSuffix(reqURL, uriEndsWith) {
|
||||||
@ -138,7 +137,7 @@ func testGetAllVolumesServiceAction(t *testing.T, uriEndsWith string, testData s
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
sess, _ := openstack.NewSession(http.DefaultClient, auth, nil)
|
sess, _ := openstack.NewSession(http.DefaultClient, auth, nil)
|
||||||
volumeService := volume_v3.Service{
|
volumeService := Service{
|
||||||
Session: *sess,
|
Session: *sess,
|
||||||
URL: apiServer.URL,
|
URL: apiServer.URL,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user