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:
Davanum Srinivas 2017-03-03 17:35:48 -05:00
parent 753e96dd4a
commit ce3bd97613
23 changed files with 105 additions and 112 deletions

View File

@ -12,7 +12,7 @@ BASE_DIR := $(shell basename $(PWD))
GOPATH_DEFAULT := $(PWD)/.go
export GOPATH ?= $(GOPATH_DEFAULT)
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)
# CTI targets

View File

@ -31,7 +31,7 @@ Code maturity is considered experimental.
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.
The lib was developed and tested on go 1.3. No external dependencies, so far.

View File

@ -18,10 +18,10 @@ package main
import (
"fmt"
// "git.openstack.org/openstack/golang-client.git/identity/v2"
// "git.openstack.org/openstack/golang-client/identity/v2"
"time"
"git.openstack.org/openstack/golang-client.git/openstack"
"git.openstack.org/openstack/golang-client/openstack"
)
// Authentication examples.

View File

@ -24,8 +24,8 @@ import (
"net/http"
"time"
"git.openstack.org/openstack/golang-client.git/objectstorage/v1"
"git.openstack.org/openstack/golang-client.git/openstack"
"git.openstack.org/openstack/golang-client/objectstorage/v1"
"git.openstack.org/openstack/golang-client/openstack"
)
func main() {

View File

@ -21,8 +21,8 @@ import (
"net/http"
"time"
"git.openstack.org/openstack/golang-client.git/image/v1"
"git.openstack.org/openstack/golang-client.git/openstack"
"git.openstack.org/openstack/golang-client/image/v1"
"git.openstack.org/openstack/golang-client/openstack"
)
// Image examples.

View File

@ -21,8 +21,8 @@ import (
"net/http"
"time"
"git.openstack.org/openstack/golang-client.git/openstack"
"git.openstack.org/openstack/golang-client.git/volume/v2"
"git.openstack.org/openstack/golang-client/openstack"
"git.openstack.org/openstack/golang-client/volume/v2"
)
// Volume examples.

View File

@ -24,7 +24,7 @@ import (
"fmt"
"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

View File

@ -1,3 +1,3 @@
package: git.openstack.org/openstack/golang-client.git
package: git.openstack.org/openstack/golang-client
import:
- package: github.com/fullsailor/pkcs7

View File

@ -17,7 +17,7 @@ package middleware
import (
"time"
"git.openstack.org/openstack/golang-client.git/openstack"
"git.openstack.org/openstack/golang-client/openstack"
)
type Validator struct {

View File

@ -30,7 +30,7 @@ import (
"strings"
"time"
"git.openstack.org/openstack/golang-client.git/openstack"
"git.openstack.org/openstack/golang-client/openstack"
"github.com/fullsailor/pkcs7"
)

View File

@ -21,7 +21,7 @@ import (
"testing"
"time"
"git.openstack.org/openstack/golang-client.git/openstack"
"git.openstack.org/openstack/golang-client/openstack"
)
const (

View File

@ -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.
*/
package image
package v1
import (
"encoding/json"
@ -30,8 +30,8 @@ import (
"net/http"
"net/url"
"git.openstack.org/openstack/golang-client.git/openstack"
"git.openstack.org/openstack/golang-client.git/util"
"git.openstack.org/openstack/golang-client/openstack"
"git.openstack.org/openstack/golang-client/util"
)
// Service is a client service that can make

View File

@ -13,7 +13,7 @@
// under the License.
// image.go
package image_test
package v1
import (
"errors"
@ -21,16 +21,15 @@ import (
"strings"
"testing"
"git.openstack.org/openstack/golang-client.git/image/v1"
"git.openstack.org/openstack/golang-client.git/openstack"
"git.openstack.org/openstack/golang-client.git/testUtil"
"git.openstack.org/openstack/golang-client.git/util"
"git.openstack.org/openstack/golang-client/openstack"
"git.openstack.org/openstack/golang-client/testUtil"
"git.openstack.org/openstack/golang-client/util"
)
var tokn = "eaaafd18-0fed-4b3a-81b4-663c99ec1cbb"
func TestListImages(t *testing.T) {
anon := func(imageService *image.Service) {
anon := func(imageService *Service) {
images, err := imageService.Images()
if err != nil {
t.Error(err)
@ -39,7 +38,7 @@ func TestListImages(t *testing.T) {
if len(images) != 3 {
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",
ContainerFormat: "bare",
DiskFormat: "qcow2",
@ -54,7 +53,7 @@ func TestListImages(t *testing.T) {
}
func TestListImageDetails(t *testing.T) {
anon := func(imageService *image.Service) {
anon := func(imageService *Service) {
images, err := imageService.ImagesDetail()
if err != nil {
t.Error(err)
@ -67,7 +66,7 @@ func TestListImageDetails(t *testing.T) {
updatedAt, _ := util.NewDateTime(`"2014-09-29T15:33:37"`)
owner := "10014302369510"
virtualSize := int64(2525125)
expectedImageDetail := image.DetailResponse{
expectedImageDetail := DetailResponse{
Status: "active",
Name: "Ubuntu Server 12.04.5 LTS (amd64 20140927) - Partner Image",
Deleted: false,
@ -109,48 +108,48 @@ func TestListImageDetails(t *testing.T) {
func TestNameFilterUrlProduced(t *testing.T) {
testImageQueryParameter(t, "images?name=CentOS+deprecated",
image.QueryParameters{Name: "CentOS deprecated"})
QueryParameters{Name: "CentOS deprecated"})
}
func TestStatusUrlProduced(t *testing.T) {
testImageQueryParameter(t, "images?status=active",
image.QueryParameters{Status: "active"})
QueryParameters{Status: "active"})
}
func TestMinMaxSizeUrlProduced(t *testing.T) {
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) {
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) {
testImageQueryParameter(t, "images?container_format=bare",
image.QueryParameters{ContainerFormat: "bare"})
QueryParameters{ContainerFormat: "bare"})
}
func TestSortKeySortUrlProduced(t *testing.T) {
testImageQueryParameter(t, "images?sort_key=id",
image.QueryParameters{SortKey: "id"})
QueryParameters{SortKey: "id"})
}
func TestSortDirSortUrlProduced(t *testing.T) {
testImageQueryParameter(t, "images?sort_dir=asc",
image.QueryParameters{SortDirection: image.Asc})
QueryParameters{SortDirection: Asc})
}
func testImageQueryParameter(t *testing.T, uriEndsWith string, queryParameters image.QueryParameters) {
anon := func(imageService *image.Service) {
func testImageQueryParameter(t *testing.T, uriEndsWith string, queryParameters QueryParameters) {
anon := func(imageService *Service) {
_, _ = imageService.QueryImages(&queryParameters)
}
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) {
reqURL := req.URL.String()
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)
imageService := image.Service{
imageService := Service{
Session: *sess,
URL: apiServer.URL,
}

View File

@ -20,8 +20,8 @@ import (
"net/url"
"strconv"
"git.openstack.org/openstack/golang-client.git/openstack"
"git.openstack.org/openstack/golang-client.git/util"
"git.openstack.org/openstack/golang-client/openstack"
"git.openstack.org/openstack/golang-client/util"
)
var zeroByte = &([]byte{}) //pointer to empty []byte

View File

@ -12,12 +12,11 @@
// License for the specific language governing permissions and limitations
// under the License.
package objectstorage_test
package objectstorage
import (
"errors"
"git.openstack.org/openstack/golang-client.git/objectstorage/v1"
"git.openstack.org/openstack/golang-client.git/openstack"
"git.openstack.org/openstack/golang-client/openstack"
"io/ioutil"
"net/http"
"net/http/httptest"
@ -49,7 +48,7 @@ func TestGetAccountMeta(t *testing.T) {
defer apiServer.Close()
sess := testGetSession()
meta, err := objectstorage.GetAccountMeta(sess, apiServer.URL)
meta, err := GetAccountMeta(sess, apiServer.URL)
if err != nil {
t.Error(err)
}
@ -80,7 +79,7 @@ func TestListContainers(t *testing.T) {
defer apiServer.Close()
sess := testGetSession()
myList, err := objectstorage.ListContainers(sess, 0, "", apiServer.URL)
myList, err := ListContainers(sess, 0, "", apiServer.URL)
if err != nil {
t.Error(err)
}
@ -115,7 +114,7 @@ func TestListObjects(t *testing.T) {
defer apiServer.Close()
sess := testGetSession()
myList, err := objectstorage.ListObjects(
myList, err := ListObjects(
sess, 0, "", "", "", "", apiServer.URL+containerPrefix)
if err != nil {
t.Error(err)
@ -137,7 +136,7 @@ func TestDeleteContainer(t *testing.T) {
defer apiServer.Close()
sess := testGetSession()
if err := objectstorage.DeleteContainer(sess, apiServer.URL+containerPrefix); err != nil {
if err := DeleteContainer(sess, apiServer.URL+containerPrefix); err != nil {
t.Error(err)
}
}
@ -157,7 +156,7 @@ func TestGetContainerMeta(t *testing.T) {
defer apiServer.Close()
sess := testGetSession()
meta, err := objectstorage.GetContainerMeta(sess, apiServer.URL+containerPrefix)
meta, err := GetContainerMeta(sess, apiServer.URL+containerPrefix)
if err != nil {
t.Error(err)
}
@ -183,7 +182,7 @@ func TestSetContainerMeta(t *testing.T) {
sess := testGetSession()
headers := http.Header{}
headers.Add("X-Container-Meta-Fruit", "Apple")
if err := objectstorage.SetContainerMeta(
if err := SetContainerMeta(
sess, apiServer.URL+containerPrefix,
headers); err != nil {
t.Error(err)
@ -205,7 +204,7 @@ func TestPutContainer(t *testing.T) {
headers := http.Header{}
headers.Add("X-TTL", "259200")
headers.Add("X-Log-Retention", "true")
if err := objectstorage.PutContainer(sess, apiServer.URL+containerPrefix,
if err := PutContainer(sess, apiServer.URL+containerPrefix,
headers); err != nil {
t.Error(err)
}
@ -239,7 +238,7 @@ func TestPutObject(t *testing.T) {
sess := testGetSession()
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)
}
}
@ -258,7 +257,7 @@ func TestCopyObject(t *testing.T) {
defer apiServer.Close()
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)
}
}
@ -278,7 +277,7 @@ func TestGetObjectMeta(t *testing.T) {
defer apiServer.Close()
sess := testGetSession()
meta, err := objectstorage.GetObjectMeta(sess, apiServer.URL+objPrefix)
meta, err := GetObjectMeta(sess, apiServer.URL+objPrefix)
if err != nil {
t.Error(err)
}
@ -302,7 +301,7 @@ func TestSetObjectMeta(t *testing.T) {
sess := testGetSession()
headers := http.Header{}
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 {
t.Error(err)
}
@ -329,7 +328,7 @@ func TestGetObject(t *testing.T) {
defer apiServer.Close()
sess := testGetSession()
hdr, body, err := objectstorage.GetObject(sess, apiServer.URL+objPrefix)
hdr, body, err := GetObject(sess, apiServer.URL+objPrefix)
if err != nil {
t.Error(err)
}
@ -356,7 +355,7 @@ func TestDeleteObject(t *testing.T) {
defer apiServer.Close()
sess := testGetSession()
if err := objectstorage.DeleteObject(sess, apiServer.URL+objPrefix); err != nil {
if err := DeleteObject(sess, apiServer.URL+objPrefix); err != nil {
t.Error(err)
}
}

View File

@ -27,7 +27,7 @@ import (
"net/http/httputil"
"net/url"
"git.openstack.org/openstack/golang-client.git/util"
"git.openstack.org/openstack/golang-client/util"
)
var Debug = new(bool)

View File

@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package openstack_test
package openstack
import (
"encoding/json"
@ -21,8 +21,7 @@ import (
"net/http"
"testing"
"git.openstack.org/openstack/golang-client.git/openstack"
"git.openstack.org/openstack/golang-client.git/testUtil"
"git.openstack.org/openstack/golang-client/testUtil"
)
type TestStruct struct {
@ -41,7 +40,7 @@ func TestSessionGet(t *testing.T) {
expected := TestStruct{ID: "id1", Name: "Chris"}
actual := TestStruct{}
s, _ := openstack.NewSession(nil, nil, nil)
s, _ := NewSession(nil, nil, nil)
var headers http.Header = http.Header{}
headers.Set("X-Auth-Token", tokn)
headers.Set("Accept", "application/json")

View File

@ -12,20 +12,19 @@
// License for the specific language governing permissions and limitations
// under the License.
package util_test
package util
import (
"encoding/json"
"testing"
"time"
"git.openstack.org/openstack/golang-client.git/testUtil"
"git.openstack.org/openstack/golang-client.git/util"
"git.openstack.org/openstack/golang-client/testUtil"
)
var testValue = `{"created_at":"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) {
bytes, _ := json.Marshal(timeTestValue)
@ -55,5 +54,5 @@ func TestUnmarshalInvalidDateTimeFormatTimeTest(t *testing.T) {
}
type timeTest struct {
CreatedAt util.RFC8601DateTime `json:"created_at"`
CreatedAt RFC8601DateTime `json:"created_at"`
}

View File

@ -12,7 +12,7 @@
// License for the specific language governing permissions and limitations
// under the License.
package util_test
package util
import (
"bytes"
@ -23,8 +23,7 @@ import (
"strconv"
"testing"
"git.openstack.org/openstack/golang-client.git/testUtil"
"git.openstack.org/openstack/golang-client.git/util"
"git.openstack.org/openstack/golang-client/testUtil"
)
var token = "2350971-5716-8165"
@ -33,7 +32,7 @@ func TestDelete(t *testing.T) {
var apiServer = testUtil.CreateDeleteTestRequestServer(t, token, "/other")
defer apiServer.Close()
err := util.Delete(apiServer.URL+"/other", token, *http.DefaultClient)
err := Delete(apiServer.URL+"/other", token, *http.DefaultClient)
testUtil.IsNil(t, err)
}
@ -43,7 +42,7 @@ func TestPostJsonWithValidResponse(t *testing.T) {
actual := TestStruct{}
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)
expected := TestStruct{ID: "id1", Name: "Chris"}
@ -60,13 +59,13 @@ func TestCallAPI(t *testing.T) {
w.WriteHeader(200) //ok
}))
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)
}
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)
}
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)
}
}
@ -90,7 +89,7 @@ func TestCallAPIGetContent(t *testing.T) {
w.Write(body)
}))
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 {
t.Error(err)
}
@ -129,7 +128,7 @@ func TestCallAPIPutContent(t *testing.T) {
}
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)
}
}

View File

@ -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.
*/
package volume_v2
package v2
import (
"encoding/json"
@ -30,8 +30,8 @@ import (
"net/http"
"net/url"
"git.openstack.org/openstack/golang-client.git/openstack"
"git.openstack.org/openstack/golang-client.git/util"
"git.openstack.org/openstack/golang-client/openstack"
"git.openstack.org/openstack/golang-client/util"
)
// Service is a client service that can make

View File

@ -13,7 +13,7 @@
// under the License.
// volume.go
package volume_v2_test
package v2
import (
"errors"
@ -21,16 +21,15 @@ import (
"strings"
"testing"
"git.openstack.org/openstack/golang-client.git/openstack"
"git.openstack.org/openstack/golang-client.git/testUtil"
"git.openstack.org/openstack/golang-client.git/util"
"git.openstack.org/openstack/golang-client.git/volume/v2"
"git.openstack.org/openstack/golang-client/openstack"
"git.openstack.org/openstack/golang-client/testUtil"
"git.openstack.org/openstack/golang-client/util"
)
var tokn = "ae5aebe5-6a5d-4a40-840a-9736a067aff4"
func TestListVolumes(t *testing.T) {
anon := func(volumeService *volume_v2.Service) {
anon := func(volumeService *Service) {
volumes, err := volumeService.Volumes()
if err != nil {
t.Error(err)
@ -39,7 +38,7 @@ func TestListVolumes(t *testing.T) {
if len(volumes) != 2 {
t.Error(errors.New("Incorrect number of volumes found"))
}
expectedVolume := volume_v2.Response{
expectedVolume := Response{
Name: "volume_test1",
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"},
@ -52,7 +51,7 @@ func TestListVolumes(t *testing.T) {
}
func TestListVolumeDetails(t *testing.T) {
anon := func(volumeService *volume_v2.Service) {
anon := func(volumeService *Service) {
volumes, err := volumeService.VolumesDetail()
if err != nil {
t.Error(err)
@ -62,7 +61,7 @@ func TestListVolumeDetails(t *testing.T) {
t.Error(errors.New("Incorrect number of volumes found"))
}
createdAt, _ := util.NewDateTime(`"2014-09-29T14:44:31"`)
expectedVolumeDetail := volume_v2.DetailResponse{
expectedVolumeDetail := DetailResponse{
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"}},
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) {
testVolumeQueryParameter(t, "volumes?limit=2",
volume_v2.QueryParameters{Limit: 2})
QueryParameters{Limit: 2})
}
func TestAll_tenantFilterUrlProduced(t *testing.T) {
testVolumeQueryParameter(t, "volumes?all_tenant=1",
volume_v2.QueryParameters{All_tenant: 1})
QueryParameters{All_tenant: 1})
}
func TestMarkerUrlProduced(t *testing.T) {
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) {
testVolumeQueryParameter(t, "volumes?sort_key=id",
volume_v2.QueryParameters{SortKey: "id"})
QueryParameters{SortKey: "id"})
}
func TestSortDirSortUrlProduced(t *testing.T) {
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) {
anon := func(volumeService *volume_v2.Service) {
func testVolumeQueryParameter(t *testing.T, uriEndsWith string, queryParameters QueryParameters) {
anon := func(volumeService *Service) {
_, _ = volumeService.QueryVolumes(&queryParameters)
}
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) {
reqURL := req.URL.String()
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)
volumeService := volume_v2.Service{
volumeService := Service{
Session: *sess,
URL: apiServer.URL,
}

View File

@ -21,7 +21,7 @@ Show and List methods can work.
*/
package volume_v3
package v3
import (
"encoding/json"
@ -30,8 +30,8 @@ import (
"net/http"
"net/url"
"git.openstack.org/openstack/golang-client.git/openstack"
"git.openstack.org/openstack/golang-client.git/util"
"git.openstack.org/openstack/golang-client/openstack"
"git.openstack.org/openstack/golang-client/util"
)
type Service struct {

View File

@ -19,7 +19,7 @@ The CRUD operation of volumes can be retrieved using the api.
*/
package volume_v3_test
package v3
import (
"errors"
@ -27,9 +27,8 @@ import (
"strings"
"testing"
"git.openstack.org/openstack/golang-client.git/openstack"
"git.openstack.org/openstack/golang-client.git/testUtil"
"git.openstack.org/openstack/golang-client.git/volume/v3"
"git.openstack.org/openstack/golang-client/openstack"
"git.openstack.org/openstack/golang-client/testUtil"
)
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
// func TestGetVolume(t *testing.T) {
// anon := func(volumeService *volume_v3.Service) {
// anon := func(volumeService *Service) {
// volID := "f5fc9874-fc89-4814-a358-23ba83a6115f"
// volume, err := volumeService.Show(volID)
// if err != nil {
// t.Error(err)
// }
// expectedVolume := volume_v3.Response{
// expectedVolume := Response{
// Name: "myvol1",
// 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"},
@ -76,7 +75,7 @@ func TestCreateVolume(t *testing.T) {
// 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) {
reqURL := req.URL.String()
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)
volumeService := volume_v3.Service{
volumeService := Service{
Session: *sess,
URL: apiServer.URL,
}
@ -102,13 +101,13 @@ func testGetVolumeServiceAction(t *testing.T, uriEndsWith string, testData strin
}
func TestGetAllVolumes(t *testing.T) {
anon := func(volumeService *volume_v3.Service) {
anon := func(volumeService *Service) {
volumes, err := volumeService.List()
if err != nil {
t.Error(err)
}
expectedVolume := volume_v3.Response{
expectedVolume := Response{
Name: "myvol1",
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"},
@ -120,7 +119,7 @@ func TestGetAllVolumes(t *testing.T) {
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) {
reqURL := req.URL.String()
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)
volumeService := volume_v3.Service{
volumeService := Service{
Session: *sess,
URL: apiServer.URL,
}