move unit tests into 'testing' directories
diff --git a/openstack/cdn/v1/services/testing/doc.go b/openstack/cdn/v1/services/testing/doc.go
new file mode 100644
index 0000000..7603f83
--- /dev/null
+++ b/openstack/cdn/v1/services/testing/doc.go
@@ -0,0 +1 @@
+package testing
diff --git a/openstack/cdn/v1/services/fixtures.go b/openstack/cdn/v1/services/testing/fixtures.go
similarity index 99%
rename from openstack/cdn/v1/services/fixtures.go
rename to openstack/cdn/v1/services/testing/fixtures.go
index 12d260e..d4093e0 100644
--- a/openstack/cdn/v1/services/fixtures.go
+++ b/openstack/cdn/v1/services/testing/fixtures.go
@@ -1,6 +1,4 @@
-// +build fixtures
-
-package services
+package testing
import (
"fmt"
diff --git a/openstack/cdn/v1/services/requests_test.go b/openstack/cdn/v1/services/testing/requests_test.go
similarity index 66%
rename from openstack/cdn/v1/services/requests_test.go
rename to openstack/cdn/v1/services/testing/requests_test.go
index 1f27b59..0abc98e 100644
--- a/openstack/cdn/v1/services/requests_test.go
+++ b/openstack/cdn/v1/services/testing/requests_test.go
@@ -1,9 +1,10 @@
-package services
+package testing
import (
"testing"
"github.com/gophercloud/gophercloud"
+ "github.com/gophercloud/gophercloud/openstack/cdn/v1/services"
"github.com/gophercloud/gophercloud/pagination"
th "github.com/gophercloud/gophercloud/testhelper"
fake "github.com/gophercloud/gophercloud/testhelper/client"
@@ -17,61 +18,61 @@
count := 0
- err := List(fake.ServiceClient(), &ListOpts{}).EachPage(func(page pagination.Page) (bool, error) {
+ err := services.List(fake.ServiceClient(), &services.ListOpts{}).EachPage(func(page pagination.Page) (bool, error) {
count++
- actual, err := ExtractServices(page)
+ actual, err := services.ExtractServices(page)
if err != nil {
t.Errorf("Failed to extract services: %v", err)
return false, err
}
- expected := []Service{
- Service{
+ expected := []services.Service{
+ {
ID: "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0",
Name: "mywebsite.com",
- Domains: []Domain{
- Domain{
+ Domains: []services.Domain{
+ {
Domain: "www.mywebsite.com",
},
},
- Origins: []Origin{
- Origin{
+ Origins: []services.Origin{
+ {
Origin: "mywebsite.com",
Port: 80,
SSL: false,
},
},
- Caching: []CacheRule{
- CacheRule{
+ Caching: []services.CacheRule{
+ {
Name: "default",
TTL: 3600,
},
- CacheRule{
+ {
Name: "home",
TTL: 17200,
- Rules: []TTLRule{
- TTLRule{
+ Rules: []services.TTLRule{
+ {
Name: "index",
RequestURL: "/index.htm",
},
},
},
- CacheRule{
+ {
Name: "images",
TTL: 12800,
- Rules: []TTLRule{
- TTLRule{
+ Rules: []services.TTLRule{
+ {
Name: "images",
RequestURL: "*.png",
},
},
},
},
- Restrictions: []Restriction{
- Restriction{
+ Restrictions: []services.Restriction{
+ {
Name: "website only",
- Rules: []RestrictionRule{
- RestrictionRule{
+ Rules: []services.RestrictionRule{
+ {
Name: "mywebsite.com",
Referrer: "www.mywebsite.com",
},
@@ -80,55 +81,55 @@
},
FlavorID: "asia",
Status: "deployed",
- Errors: []Error{},
+ Errors: []services.Error{},
Links: []gophercloud.Link{
- gophercloud.Link{
+ {
Href: "https://www.poppycdn.io/v1.0/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0",
Rel: "self",
},
- gophercloud.Link{
+ {
Href: "mywebsite.com.cdn123.poppycdn.net",
Rel: "access_url",
},
- gophercloud.Link{
+ {
Href: "https://www.poppycdn.io/v1.0/flavors/asia",
Rel: "flavor",
},
},
},
- Service{
+ {
ID: "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f1",
Name: "myothersite.com",
- Domains: []Domain{
- Domain{
+ Domains: []services.Domain{
+ {
Domain: "www.myothersite.com",
},
},
- Origins: []Origin{
- Origin{
+ Origins: []services.Origin{
+ {
Origin: "44.33.22.11",
Port: 80,
SSL: false,
},
- Origin{
+ {
Origin: "77.66.55.44",
Port: 80,
SSL: false,
- Rules: []OriginRule{
- OriginRule{
+ Rules: []services.OriginRule{
+ {
Name: "videos",
RequestURL: "^/videos/*.m3u",
},
},
},
},
- Caching: []CacheRule{
- CacheRule{
+ Caching: []services.CacheRule{
+ {
Name: "default",
TTL: 3600,
},
},
- Restrictions: []Restriction{},
+ Restrictions: []services.Restriction{},
FlavorID: "europe",
Status: "deployed",
Links: []gophercloud.Link{
@@ -165,36 +166,36 @@
HandleCreateCDNServiceSuccessfully(t)
- createOpts := CreateOpts{
+ createOpts := services.CreateOpts{
Name: "mywebsite.com",
- Domains: []Domain{
- Domain{
+ Domains: []services.Domain{
+ {
Domain: "www.mywebsite.com",
},
- Domain{
+ {
Domain: "blog.mywebsite.com",
},
},
- Origins: []Origin{
- Origin{
+ Origins: []services.Origin{
+ {
Origin: "mywebsite.com",
Port: 80,
SSL: false,
},
},
- Restrictions: []Restriction{
- Restriction{
+ Restrictions: []services.Restriction{
+ {
Name: "website only",
- Rules: []RestrictionRule{
- RestrictionRule{
+ Rules: []services.RestrictionRule{
+ {
Name: "mywebsite.com",
Referrer: "www.mywebsite.com",
},
},
},
},
- Caching: []CacheRule{
- CacheRule{
+ Caching: []services.CacheRule{
+ {
Name: "default",
TTL: 3600,
},
@@ -203,7 +204,7 @@
}
expected := "https://global.cdn.api.rackspacecloud.com/v1.0/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0"
- actual, err := Create(fake.ServiceClient(), createOpts).Extract()
+ actual, err := services.Create(fake.ServiceClient(), createOpts).Extract()
th.AssertNoErr(t, err)
th.AssertEquals(t, expected, actual)
}
@@ -214,53 +215,53 @@
HandleGetCDNServiceSuccessfully(t)
- expected := &Service{
+ expected := &services.Service{
ID: "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0",
Name: "mywebsite.com",
- Domains: []Domain{
- Domain{
+ Domains: []services.Domain{
+ {
Domain: "www.mywebsite.com",
Protocol: "http",
},
},
- Origins: []Origin{
- Origin{
+ Origins: []services.Origin{
+ {
Origin: "mywebsite.com",
Port: 80,
SSL: false,
},
},
- Caching: []CacheRule{
- CacheRule{
+ Caching: []services.CacheRule{
+ {
Name: "default",
TTL: 3600,
},
- CacheRule{
+ {
Name: "home",
TTL: 17200,
- Rules: []TTLRule{
- TTLRule{
+ Rules: []services.TTLRule{
+ {
Name: "index",
RequestURL: "/index.htm",
},
},
},
- CacheRule{
+ {
Name: "images",
TTL: 12800,
- Rules: []TTLRule{
- TTLRule{
+ Rules: []services.TTLRule{
+ {
Name: "images",
RequestURL: "*.png",
},
},
},
},
- Restrictions: []Restriction{
- Restriction{
+ Restrictions: []services.Restriction{
+ {
Name: "website only",
- Rules: []RestrictionRule{
- RestrictionRule{
+ Rules: []services.RestrictionRule{
+ {
Name: "mywebsite.com",
Referrer: "www.mywebsite.com",
},
@@ -269,24 +270,24 @@
},
FlavorID: "cdn",
Status: "deployed",
- Errors: []Error{},
+ Errors: []services.Error{},
Links: []gophercloud.Link{
- gophercloud.Link{
+ {
Href: "https://global.cdn.api.rackspacecloud.com/v1.0/110011/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0",
Rel: "self",
},
- gophercloud.Link{
+ {
Href: "blog.mywebsite.com.cdn1.raxcdn.com",
Rel: "access_url",
},
- gophercloud.Link{
+ {
Href: "https://global.cdn.api.rackspacecloud.com/v1.0/110011/flavors/cdn",
Rel: "flavor",
},
},
}
- actual, err := Get(fake.ServiceClient(), "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0").Extract()
+ actual, err := services.Get(fake.ServiceClient(), "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0").Extract()
th.AssertNoErr(t, err)
th.AssertDeepEquals(t, expected, actual)
}
@@ -298,51 +299,51 @@
HandleUpdateCDNServiceSuccessfully(t)
expected := "https://www.poppycdn.io/v1.0/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0"
- ops := UpdateOpts{
+ ops := services.UpdateOpts{
// Append a single Domain
- Append{Value: Domain{Domain: "appended.mocksite4.com"}},
+ services.Append{Value: services.Domain{Domain: "appended.mocksite4.com"}},
// Insert a single Domain
- Insertion{
+ services.Insertion{
Index: 4,
- Value: Domain{Domain: "inserted.mocksite4.com"},
+ Value: services.Domain{Domain: "inserted.mocksite4.com"},
},
// Bulk addition
- Append{
- Value: DomainList{
- Domain{Domain: "bulkadded1.mocksite4.com"},
- Domain{Domain: "bulkadded2.mocksite4.com"},
+ services.Append{
+ Value: services.DomainList{
+ {Domain: "bulkadded1.mocksite4.com"},
+ {Domain: "bulkadded2.mocksite4.com"},
},
},
// Replace a single Origin
- Replacement{
+ services.Replacement{
Index: 2,
- Value: Origin{Origin: "44.33.22.11", Port: 80, SSL: false},
+ Value: services.Origin{Origin: "44.33.22.11", Port: 80, SSL: false},
},
// Bulk replace Origins
- Replacement{
+ services.Replacement{
Index: 0, // Ignored
- Value: OriginList{
- Origin{Origin: "44.33.22.11", Port: 80, SSL: false},
- Origin{Origin: "55.44.33.22", Port: 443, SSL: true},
+ Value: services.OriginList{
+ {Origin: "44.33.22.11", Port: 80, SSL: false},
+ {Origin: "55.44.33.22", Port: 443, SSL: true},
},
},
// Remove a single CacheRule
- Removal{
+ services.Removal{
Index: 8,
- Path: PathCaching,
+ Path: services.PathCaching,
},
// Bulk removal
- Removal{
+ services.Removal{
All: true,
- Path: PathCaching,
+ Path: services.PathCaching,
},
// Service name replacement
- NameReplacement{
+ services.NameReplacement{
NewName: "differentServiceName",
},
}
- actual, err := Update(fake.ServiceClient(), "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0", ops).Extract()
+ actual, err := services.Update(fake.ServiceClient(), "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0", ops).Extract()
th.AssertNoErr(t, err)
th.AssertEquals(t, expected, actual)
}
@@ -353,6 +354,6 @@
HandleDeleteCDNServiceSuccessfully(t)
- err := Delete(fake.ServiceClient(), "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0").ExtractErr()
+ err := services.Delete(fake.ServiceClient(), "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0").ExtractErr()
th.AssertNoErr(t, err)
}