move unit tests into 'testing' directories
diff --git a/pagination/testing/doc.go b/pagination/testing/doc.go
new file mode 100644
index 0000000..7603f83
--- /dev/null
+++ b/pagination/testing/doc.go
@@ -0,0 +1 @@
+package testing
diff --git a/pagination/linked_test.go b/pagination/testing/linked_test.go
similarity index 82%
rename from pagination/linked_test.go
rename to pagination/testing/linked_test.go
index 67e6e3c..3533e44 100644
--- a/pagination/linked_test.go
+++ b/pagination/testing/linked_test.go
@@ -1,4 +1,4 @@
-package pagination
+package testing
import (
"fmt"
@@ -6,13 +6,14 @@
"reflect"
"testing"
+ "github.com/gophercloud/gophercloud/pagination"
"github.com/gophercloud/gophercloud/testhelper"
)
// LinkedPager sample and test cases.
type LinkedPageResult struct {
- LinkedPageBase
+ pagination.LinkedPageBase
}
func (r LinkedPageResult) IsEmpty() (bool, error) {
@@ -20,7 +21,7 @@
return len(is) == 0, err
}
-func ExtractLinkedInts(r Page) ([]int, error) {
+func ExtractLinkedInts(r pagination.Page) ([]int, error) {
var s struct {
Ints []int `json:"ints"`
}
@@ -28,7 +29,7 @@
return s.Ints, err
}
-func createLinked(t *testing.T) Pager {
+func createLinked(t *testing.T) pagination.Pager {
testhelper.SetupHTTP()
testhelper.Mux.HandleFunc("/page1", func(w http.ResponseWriter, r *http.Request) {
@@ -48,11 +49,11 @@
client := createClient()
- createPage := func(r PageResult) Page {
- return LinkedPageResult{LinkedPageBase{PageResult: r}}
+ createPage := func(r pagination.PageResult) pagination.Page {
+ return LinkedPageResult{pagination.LinkedPageBase{PageResult: r}}
}
- return NewPager(client, testhelper.Server.URL+"/page1", createPage)
+ return pagination.NewPager(client, testhelper.Server.URL+"/page1", createPage)
}
func TestEnumerateLinked(t *testing.T) {
@@ -60,7 +61,7 @@
defer testhelper.TeardownHTTP()
callCount := 0
- err := pager.EachPage(func(page Page) (bool, error) {
+ err := pager.EachPage(func(page pagination.Page) (bool, error) {
actual, err := ExtractLinkedInts(page)
if err != nil {
return false, err
diff --git a/pagination/marker_test.go b/pagination/testing/marker_test.go
similarity index 83%
rename from pagination/marker_test.go
rename to pagination/testing/marker_test.go
index 4ade8d3..7b1a6da 100644
--- a/pagination/marker_test.go
+++ b/pagination/testing/marker_test.go
@@ -1,4 +1,4 @@
-package pagination
+package testing
import (
"fmt"
@@ -6,13 +6,14 @@
"strings"
"testing"
+ "github.com/gophercloud/gophercloud/pagination"
"github.com/gophercloud/gophercloud/testhelper"
)
// MarkerPager sample and test cases.
type MarkerPageResult struct {
- MarkerPageBase
+ pagination.MarkerPageBase
}
func (r MarkerPageResult) IsEmpty() (bool, error) {
@@ -34,7 +35,7 @@
return results[len(results)-1], nil
}
-func createMarkerPaged(t *testing.T) Pager {
+func createMarkerPaged(t *testing.T) pagination.Pager {
testhelper.SetupHTTP()
testhelper.Mux.HandleFunc("/page", func(w http.ResponseWriter, r *http.Request) {
@@ -56,16 +57,16 @@
client := createClient()
- createPage := func(r PageResult) Page {
- p := MarkerPageResult{MarkerPageBase{PageResult: r}}
+ createPage := func(r pagination.PageResult) pagination.Page {
+ p := MarkerPageResult{pagination.MarkerPageBase{PageResult: r}}
p.MarkerPageBase.Owner = p
return p
}
- return NewPager(client, testhelper.Server.URL+"/page", createPage)
+ return pagination.NewPager(client, testhelper.Server.URL+"/page", createPage)
}
-func ExtractMarkerStrings(page Page) ([]string, error) {
+func ExtractMarkerStrings(page pagination.Page) ([]string, error) {
content := page.(MarkerPageResult).Body.([]uint8)
parts := strings.Split(string(content), "\n")
results := make([]string, 0, len(parts))
@@ -82,7 +83,7 @@
defer testhelper.TeardownHTTP()
callCount := 0
- err := pager.EachPage(func(page Page) (bool, error) {
+ err := pager.EachPage(func(page pagination.Page) (bool, error) {
actual, err := ExtractMarkerStrings(page)
if err != nil {
return false, err
diff --git a/pagination/pagination_test.go b/pagination/testing/pagination_test.go
similarity index 93%
rename from pagination/pagination_test.go
rename to pagination/testing/pagination_test.go
index bd3295e..170dca4 100644
--- a/pagination/pagination_test.go
+++ b/pagination/testing/pagination_test.go
@@ -1,4 +1,4 @@
-package pagination
+package testing
import (
"github.com/gophercloud/gophercloud"
diff --git a/pagination/single_test.go b/pagination/testing/single_test.go
similarity index 75%
rename from pagination/single_test.go
rename to pagination/testing/single_test.go
index 2a9466c..8d95e94 100644
--- a/pagination/single_test.go
+++ b/pagination/testing/single_test.go
@@ -1,17 +1,18 @@
-package pagination
+package testing
import (
"fmt"
"net/http"
"testing"
+ "github.com/gophercloud/gophercloud/pagination"
"github.com/gophercloud/gophercloud/testhelper"
)
// SinglePage sample and test cases.
type SinglePageResult struct {
- SinglePageBase
+ pagination.SinglePageBase
}
func (r SinglePageResult) IsEmpty() (bool, error) {
@@ -22,7 +23,7 @@
return len(is) == 0, nil
}
-func ExtractSingleInts(r Page) ([]int, error) {
+func ExtractSingleInts(r pagination.Page) ([]int, error) {
var s struct {
Ints []int `json:"ints"`
}
@@ -30,7 +31,7 @@
return s.Ints, err
}
-func setupSinglePaged() Pager {
+func setupSinglePaged() pagination.Pager {
testhelper.SetupHTTP()
client := createClient()
@@ -39,11 +40,11 @@
fmt.Fprintf(w, `{ "ints": [1, 2, 3] }`)
})
- createPage := func(r PageResult) Page {
- return SinglePageResult{SinglePageBase(r)}
+ createPage := func(r pagination.PageResult) pagination.Page {
+ return SinglePageResult{pagination.SinglePageBase(r)}
}
- return NewPager(client, testhelper.Server.URL+"/only", createPage)
+ return pagination.NewPager(client, testhelper.Server.URL+"/only", createPage)
}
func TestEnumerateSinglePaged(t *testing.T) {
@@ -51,7 +52,7 @@
pager := setupSinglePaged()
defer testhelper.TeardownHTTP()
- err := pager.EachPage(func(page Page) (bool, error) {
+ err := pager.EachPage(func(page pagination.Page) (bool, error) {
callCount++
expected := []int{1, 2, 3}