Clean-up dependencies

Signed-off-by: David Gageot <david@gageot.net>
This commit is contained in:
David Gageot
2015-11-12 19:16:27 +01:00
parent 7a4915e999
commit 89675067eb
612 changed files with 1869 additions and 151003 deletions

View File

@@ -1,32 +0,0 @@
package accounts
import (
"testing"
th "github.com/rackspace/gophercloud/testhelper"
fake "github.com/rackspace/gophercloud/testhelper/client"
)
func TestUpdateAccount(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleUpdateAccountSuccessfully(t)
options := &UpdateOpts{Metadata: map[string]string{"gophercloud-test": "accounts"}}
res := Update(fake.ServiceClient(), options)
th.AssertNoErr(t, res.Err)
}
func TestGetAccount(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleGetAccountSuccessfully(t)
expectedMetadata := map[string]string{"Subject": "books"}
res := Get(fake.ServiceClient(), &GetOpts{})
th.AssertNoErr(t, res.Err)
actualMetadata, _ := res.ExtractMetadata()
th.CheckDeepEquals(t, expectedMetadata, actualMetadata)
//headers, err := res.Extract()
//th.AssertNoErr(t, err)
}

View File

@@ -1,26 +0,0 @@
package accounts
import (
"testing"
"github.com/rackspace/gophercloud"
th "github.com/rackspace/gophercloud/testhelper"
)
const endpoint = "http://localhost:57909/"
func endpointClient() *gophercloud.ServiceClient {
return &gophercloud.ServiceClient{Endpoint: endpoint}
}
func TestGetURL(t *testing.T) {
actual := getURL(endpointClient())
expected := endpoint
th.CheckEquals(t, expected, actual)
}
func TestUpdateURL(t *testing.T) {
actual := updateURL(endpointClient())
expected := endpoint
th.CheckEquals(t, expected, actual)
}

View File

@@ -1,117 +0,0 @@
package containers
import (
"testing"
"github.com/rackspace/gophercloud/pagination"
th "github.com/rackspace/gophercloud/testhelper"
fake "github.com/rackspace/gophercloud/testhelper/client"
)
var metadata = map[string]string{"gophercloud-test": "containers"}
func TestListContainerInfo(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleListContainerInfoSuccessfully(t)
count := 0
err := List(fake.ServiceClient(), &ListOpts{Full: true}).EachPage(func(page pagination.Page) (bool, error) {
count++
actual, err := ExtractInfo(page)
th.AssertNoErr(t, err)
th.CheckDeepEquals(t, ExpectedListInfo, actual)
return true, nil
})
th.AssertNoErr(t, err)
th.CheckEquals(t, count, 1)
}
func TestListAllContainerInfo(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleListContainerInfoSuccessfully(t)
allPages, err := List(fake.ServiceClient(), &ListOpts{Full: true}).AllPages()
th.AssertNoErr(t, err)
actual, err := ExtractInfo(allPages)
th.AssertNoErr(t, err)
th.CheckDeepEquals(t, ExpectedListInfo, actual)
}
func TestListContainerNames(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleListContainerNamesSuccessfully(t)
count := 0
err := List(fake.ServiceClient(), &ListOpts{Full: false}).EachPage(func(page pagination.Page) (bool, error) {
count++
actual, err := ExtractNames(page)
if err != nil {
t.Errorf("Failed to extract container names: %v", err)
return false, err
}
th.CheckDeepEquals(t, ExpectedListNames, actual)
return true, nil
})
th.AssertNoErr(t, err)
th.CheckEquals(t, count, 1)
}
func TestListAllContainerNames(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleListContainerNamesSuccessfully(t)
allPages, err := List(fake.ServiceClient(), &ListOpts{Full: false}).AllPages()
th.AssertNoErr(t, err)
actual, err := ExtractNames(allPages)
th.AssertNoErr(t, err)
th.CheckDeepEquals(t, ExpectedListNames, actual)
}
func TestCreateContainer(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleCreateContainerSuccessfully(t)
options := CreateOpts{ContentType: "application/json", Metadata: map[string]string{"foo": "bar"}}
res := Create(fake.ServiceClient(), "testContainer", options)
c, err := res.Extract()
th.CheckNoErr(t, err)
th.CheckEquals(t, "bar", res.Header["X-Container-Meta-Foo"][0])
th.CheckEquals(t, "1234567", c.TransID)
}
func TestDeleteContainer(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleDeleteContainerSuccessfully(t)
res := Delete(fake.ServiceClient(), "testContainer")
th.CheckNoErr(t, res.Err)
}
func TestUpateContainer(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleUpdateContainerSuccessfully(t)
options := &UpdateOpts{Metadata: map[string]string{"foo": "bar"}}
res := Update(fake.ServiceClient(), "testContainer", options)
th.CheckNoErr(t, res.Err)
}
func TestGetContainer(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleGetContainerSuccessfully(t)
_, err := Get(fake.ServiceClient(), "testContainer").ExtractMetadata()
th.CheckNoErr(t, err)
}

View File

@@ -1,43 +0,0 @@
package containers
import (
"github.com/rackspace/gophercloud"
th "github.com/rackspace/gophercloud/testhelper"
"testing"
)
const endpoint = "http://localhost:57909/"
func endpointClient() *gophercloud.ServiceClient {
return &gophercloud.ServiceClient{Endpoint: endpoint}
}
func TestListURL(t *testing.T) {
actual := listURL(endpointClient())
expected := endpoint
th.CheckEquals(t, expected, actual)
}
func TestCreateURL(t *testing.T) {
actual := createURL(endpointClient(), "foo")
expected := endpoint + "foo"
th.CheckEquals(t, expected, actual)
}
func TestGetURL(t *testing.T) {
actual := getURL(endpointClient(), "foo")
expected := endpoint + "foo"
th.CheckEquals(t, expected, actual)
}
func TestDeleteURL(t *testing.T) {
actual := deleteURL(endpointClient(), "foo")
expected := endpoint + "foo"
th.CheckEquals(t, expected, actual)
}
func TestUpdateURL(t *testing.T) {
actual := updateURL(endpointClient(), "foo")
expected := endpoint + "foo"
th.CheckEquals(t, expected, actual)
}

View File

@@ -1,142 +0,0 @@
package objects
import (
"bytes"
"io"
"testing"
"github.com/rackspace/gophercloud/pagination"
th "github.com/rackspace/gophercloud/testhelper"
fake "github.com/rackspace/gophercloud/testhelper/client"
)
func TestDownloadReader(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleDownloadObjectSuccessfully(t)
response := Download(fake.ServiceClient(), "testContainer", "testObject", nil)
defer response.Body.Close()
// Check reader
buf := bytes.NewBuffer(make([]byte, 0))
io.CopyN(buf, response.Body, 10)
th.CheckEquals(t, "Successful", string(buf.Bytes()))
}
func TestDownloadExtraction(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleDownloadObjectSuccessfully(t)
response := Download(fake.ServiceClient(), "testContainer", "testObject", nil)
// Check []byte extraction
bytes, err := response.ExtractContent()
th.AssertNoErr(t, err)
th.CheckEquals(t, "Successful download with Gophercloud", string(bytes))
}
func TestListObjectInfo(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleListObjectsInfoSuccessfully(t)
count := 0
options := &ListOpts{Full: true}
err := List(fake.ServiceClient(), "testContainer", options).EachPage(func(page pagination.Page) (bool, error) {
count++
actual, err := ExtractInfo(page)
th.AssertNoErr(t, err)
th.CheckDeepEquals(t, ExpectedListInfo, actual)
return true, nil
})
th.AssertNoErr(t, err)
th.CheckEquals(t, count, 1)
}
func TestListObjectNames(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleListObjectNamesSuccessfully(t)
count := 0
options := &ListOpts{Full: false}
err := List(fake.ServiceClient(), "testContainer", options).EachPage(func(page pagination.Page) (bool, error) {
count++
actual, err := ExtractNames(page)
if err != nil {
t.Errorf("Failed to extract container names: %v", err)
return false, err
}
th.CheckDeepEquals(t, ExpectedListNames, actual)
return true, nil
})
th.AssertNoErr(t, err)
th.CheckEquals(t, count, 1)
}
func TestCreateObject(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleCreateTextObjectSuccessfully(t)
content := bytes.NewBufferString("Did gyre and gimble in the wabe")
options := &CreateOpts{ContentType: "text/plain"}
res := Create(fake.ServiceClient(), "testContainer", "testObject", content, options)
th.AssertNoErr(t, res.Err)
}
func TestCreateObjectWithoutContentType(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleCreateTypelessObjectSuccessfully(t)
content := bytes.NewBufferString("The sky was the color of television, tuned to a dead channel.")
res := Create(fake.ServiceClient(), "testContainer", "testObject", content, &CreateOpts{})
th.AssertNoErr(t, res.Err)
}
func TestCopyObject(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleCopyObjectSuccessfully(t)
options := &CopyOpts{Destination: "/newTestContainer/newTestObject"}
res := Copy(fake.ServiceClient(), "testContainer", "testObject", options)
th.AssertNoErr(t, res.Err)
}
func TestDeleteObject(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleDeleteObjectSuccessfully(t)
res := Delete(fake.ServiceClient(), "testContainer", "testObject", nil)
th.AssertNoErr(t, res.Err)
}
func TestUpateObjectMetadata(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleUpdateObjectSuccessfully(t)
options := &UpdateOpts{Metadata: map[string]string{"Gophercloud-Test": "objects"}}
res := Update(fake.ServiceClient(), "testContainer", "testObject", options)
th.AssertNoErr(t, res.Err)
}
func TestGetObject(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleGetObjectSuccessfully(t)
expected := map[string]string{"Gophercloud-Test": "objects"}
actual, err := Get(fake.ServiceClient(), "testContainer", "testObject", nil).ExtractMetadata()
th.AssertNoErr(t, err)
th.CheckDeepEquals(t, expected, actual)
}

View File

@@ -1,56 +0,0 @@
package objects
import (
"testing"
"github.com/rackspace/gophercloud"
th "github.com/rackspace/gophercloud/testhelper"
)
const endpoint = "http://localhost:57909/"
func endpointClient() *gophercloud.ServiceClient {
return &gophercloud.ServiceClient{Endpoint: endpoint}
}
func TestListURL(t *testing.T) {
actual := listURL(endpointClient(), "foo")
expected := endpoint + "foo"
th.CheckEquals(t, expected, actual)
}
func TestCopyURL(t *testing.T) {
actual := copyURL(endpointClient(), "foo", "bar")
expected := endpoint + "foo/bar"
th.CheckEquals(t, expected, actual)
}
func TestCreateURL(t *testing.T) {
actual := createURL(endpointClient(), "foo", "bar")
expected := endpoint + "foo/bar"
th.CheckEquals(t, expected, actual)
}
func TestGetURL(t *testing.T) {
actual := getURL(endpointClient(), "foo", "bar")
expected := endpoint + "foo/bar"
th.CheckEquals(t, expected, actual)
}
func TestDeleteURL(t *testing.T) {
actual := deleteURL(endpointClient(), "foo", "bar")
expected := endpoint + "foo/bar"
th.CheckEquals(t, expected, actual)
}
func TestDownloadURL(t *testing.T) {
actual := downloadURL(endpointClient(), "foo", "bar")
expected := endpoint + "foo/bar"
th.CheckEquals(t, expected, actual)
}
func TestUpdateURL(t *testing.T) {
actual := updateURL(endpointClient(), "foo", "bar")
expected := endpoint + "foo/bar"
th.CheckEquals(t, expected, actual)
}