Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions test/integration/domains_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package integration

import (
"context"
"strings"
"testing"

"github.com/linode/linodego/v2"
"github.com/stretchr/testify/require"
)

var testDomainCreateOpts = linodego.DomainCreateOptions{
Expand Down Expand Up @@ -114,21 +116,22 @@ func TestDomain_Clone_smoke(t *testing.T) {
t.Errorf("Error creating domain: %v", err)
}

domainPrefix, topLevelDomain, found := strings.Cut(domainToClone.Domain, "-test")
require.True(t, found)

domain, err := client.CloneDomain(context.Background(), domainToClone.ID, linodego.DomainCloneOptions{
Domain: "linodego-domain-clone.com",
Domain: domainPrefix + "-test-cloned" + topLevelDomain,
})
if err != nil {
t.Errorf("Error cloning domain, expected struct, got error %v", err)
}

cloneTeardown := func() {
t.Cleanup(func() {
if err := client.DeleteDomain(context.Background(), domain.ID); err != nil {
t.Errorf("Expected to delete a domain, but got %v", err)
}
teardown()
}

defer cloneTeardown()
})

// when comparing fixtures to random value Domain will differ
if domain.SOAEmail != domainToClone.SOAEmail {
Expand Down
62 changes: 25 additions & 37 deletions test/integration/fixtures/TestDomain_Clone.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
version: 1
interactions:
- request:
body: '{"domain":"linodego-blue-test.com","type":"master","soa_email":"example@example.com","master_ips":null,"axfr_ips":null,"tags":null}'
body: '{"domain":"linodego-blue-245372-test.com","type":"master","soa_email":"example@example.com","master_ips":null,"axfr_ips":null,"tags":null}'
form: {}
headers:
Accept:
Expand All @@ -14,11 +14,11 @@ interactions:
url: https://api.linode.com/v4beta/domains
method: POST
response:
body: '{"id": 3163304, "type": "master", "domain": "linodego-blue-test.com", "tags":
[], "group": "", "status": "active", "errors": "", "description": "", "soa_email":
"example@example.com", "retry_sec": 0, "master_ips": [], "axfr_ips": [], "expire_sec":
0, "refresh_sec": 0, "ttl_sec": 0, "created": "2018-01-02T03:04:05", "updated":
"2018-01-02T03:04:05"}'
body: '{"id": 3697372, "type": "master", "domain": "linodego-blue-245372-test.com",
"tags": [], "group": "", "status": "active", "errors": "", "description": "",
"soa_email": "example@example.com", "retry_sec": 0, "master_ips": [], "axfr_ips":
[], "expire_sec": 0, "refresh_sec": 0, "ttl_sec": 0, "created": "2018-01-02T03:04:05",
"updated": "2018-01-02T03:04:05"}'
headers:
Access-Control-Allow-Credentials:
- "true"
Expand All @@ -37,13 +37,13 @@ interactions:
Connection:
- keep-alive
Content-Length:
- "350"
- "357"
Content-Security-Policy:
- default-src 'none'
Content-Type:
- application/json
Expires:
- Tue, 19 Nov 2024 15:25:43 GMT
- Wed, 21 Oct 2026 11:32:20 GMT
Pragma:
- no-cache
Strict-Transport-Security:
Expand All @@ -58,19 +58,16 @@ interactions:
- DENY
- DENY
X-Oauth-Scopes:
- account:read_write databases:read_write domains:read_write events:read_write
firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write
longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write
volumes:read_write vpc:read_write
- '*'
X-Ratelimit-Limit:
- "1600"
- "1840"
X-Xss-Protection:
- 1; mode=block
status: 200 OK
code: 200
duration: ""
- request:
body: '{"domain":"linodego-domain-clone.com"}'
body: '{"domain":"linodego-blue-245372-test-cloned.com"}'
form: {}
headers:
Accept:
Expand All @@ -79,10 +76,10 @@ interactions:
- application/json
User-Agent:
- linodego/dev https://github.com/linode/linodego
url: https://api.linode.com/v4beta/domains/3163304/clone
url: https://api.linode.com/v4beta/domains/3697372/clone
method: POST
response:
body: '{"id": 3163305, "type": "master", "domain": "linodego-domain-clone.com",
body: '{"id": 3697373, "type": "master", "domain": "linodego-blue-245372-test-cloned.com",
"tags": [], "group": "", "status": "active", "errors": "", "description": "",
"soa_email": "example@example.com", "retry_sec": 0, "master_ips": [], "axfr_ips":
[], "expire_sec": 0, "refresh_sec": 0, "ttl_sec": 0, "created": "2018-01-02T03:04:05",
Expand All @@ -105,13 +102,13 @@ interactions:
Connection:
- keep-alive
Content-Length:
- "353"
- "364"
Content-Security-Policy:
- default-src 'none'
Content-Type:
- application/json
Expires:
- Tue, 19 Nov 2024 15:25:45 GMT
- Wed, 21 Oct 2026 11:32:23 GMT
Pragma:
- no-cache
Strict-Transport-Security:
Expand All @@ -126,12 +123,9 @@ interactions:
- DENY
- DENY
X-Oauth-Scopes:
- account:read_write databases:read_write domains:read_write events:read_write
firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write
longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write
volumes:read_write vpc:read_write
- '*'
X-Ratelimit-Limit:
- "1600"
- "1840"
X-Xss-Protection:
- 1; mode=block
status: 200 OK
Expand All @@ -147,7 +141,7 @@ interactions:
- application/json
User-Agent:
- linodego/dev https://github.com/linode/linodego
url: https://api.linode.com/v4beta/domains/3163305
url: https://api.linode.com/v4beta/domains/3697373
method: DELETE
response:
body: '{}'
Expand Down Expand Up @@ -175,7 +169,7 @@ interactions:
Content-Type:
- application/json
Expires:
- Tue, 19 Nov 2024 15:25:45 GMT
- Wed, 21 Oct 2026 11:32:24 GMT
Pragma:
- no-cache
Strict-Transport-Security:
Expand All @@ -190,12 +184,9 @@ interactions:
- DENY
- DENY
X-Oauth-Scopes:
- account:read_write databases:read_write domains:read_write events:read_write
firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write
longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write
volumes:read_write vpc:read_write
- '*'
X-Ratelimit-Limit:
- "1600"
- "1840"
X-Xss-Protection:
- 1; mode=block
status: 200 OK
Expand All @@ -211,7 +202,7 @@ interactions:
- application/json
User-Agent:
- linodego/dev https://github.com/linode/linodego
url: https://api.linode.com/v4beta/domains/3163304
url: https://api.linode.com/v4beta/domains/3697372
method: DELETE
response:
body: '{}'
Expand Down Expand Up @@ -239,7 +230,7 @@ interactions:
Content-Type:
- application/json
Expires:
- Tue, 19 Nov 2024 15:25:45 GMT
- Wed, 21 Oct 2026 11:32:24 GMT
Pragma:
- no-cache
Strict-Transport-Security:
Expand All @@ -254,12 +245,9 @@ interactions:
- DENY
- DENY
X-Oauth-Scopes:
- account:read_write databases:read_write domains:read_write events:read_write
firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write
longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write
volumes:read_write vpc:read_write
- '*'
X-Ratelimit-Limit:
- "1600"
- "1840"
X-Xss-Protection:
- 1; mode=block
status: 200 OK
Expand Down
Loading