Skip to content

Commit

Permalink
add test fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
yec-akamai committed Aug 17, 2023
1 parent b05f3d5 commit d22fb85
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 9 deletions.
25 changes: 21 additions & 4 deletions test/integration/betas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,26 @@ func TestBetaPrograms_List(t *testing.T) {
t.Errorf("Error getting Beta programs, expected struct, got error %v", err)
}

// TODO: assert data after actual data can be retrieved from API.
// No data is expected to be returned temporarily.
if len(betas) != 0 {
t.Errorf("Expected to see none beta program returned.")
if len(betas) == 0 {
t.Errorf("Expected to see beta program returned.")
} else {
assertDateSet(t, betas[0].Started)
}
}

func TestBetaProgram_Get(t *testing.T) {
client, teardown := createTestClient(t, "fixtures/TestBetaProgram_Get")
defer teardown()

betaID := "active_closed"
beta, err := client.GetBetaProgram(context.Background(), betaID)

if err != nil {
t.Errorf("Error getting Beta program, expected struct, got error %v", err)
}

if beta.ID != betaID {
t.Errorf("expected beta ID to be %s; got %s", betaID, beta.ID)
}

}
62 changes: 62 additions & 0 deletions test/integration/fixtures/TestBetaProgram_Get.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
version: 1
interactions:
- request:
body: ""
form: {}
headers:
Accept:
- application/json
Content-Type:
- application/json
User-Agent:
- linodego/dev https://github.com/linode/linodego
url: https://api.dev.linode.com/v4beta/betas/active_closed
method: GET
response:
body: '{"id": "active_closed", "label": "active closed beta", "description": "An
active closed beta", "started": "2018-01-02T03:04:05", "ended": null, "greenlight_only":
true, "more_info": "a link with even more info"}'
headers:
Access-Control-Allow-Credentials:
- "true"
Access-Control-Allow-Headers:
- Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter
Access-Control-Allow-Methods:
- HEAD, GET, OPTIONS, POST, PUT, DELETE
Access-Control-Allow-Origin:
- '*'
Access-Control-Expose-Headers:
- X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status
Cache-Control:
- private, max-age=0, s-maxage=0, no-cache, no-store
- private, max-age=60, s-maxage=60
Content-Length:
- "211"
Content-Security-Policy:
- default-src 'none'
Content-Type:
- application/json
Server:
- nginx
Strict-Transport-Security:
- max-age=31536000
Vary:
- Authorization, X-Filter
- Authorization, X-Filter
X-Accepted-Oauth-Scopes:
- '*'
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- DENY
- DENY
X-Oauth-Scopes:
- '*'
X-Ratelimit-Limit:
- "1200"
X-Xss-Protection:
- 1; mode=block
status: 200 OK
code: 200
duration: ""
14 changes: 9 additions & 5 deletions test/integration/fixtures/TestBetaPrograms_List.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@ interactions:
- application/json
User-Agent:
- linodego/dev https://github.com/linode/linodego
url: https://api.linode.com/v4beta/betas
url: https://api.dev.linode.com/v4beta/betas
method: GET
response:
body: '{"data": [], "page": 1, "pages": 1, "results": 0}'
body: '{"data": [{"id": "active_closed", "label": "active closed beta",
"description": "An active closed beta", "started": "2023-07-19T15:23:43",
"ended": null, "greenlight_only": true, "more_info": "a link with even more info"},
{"id": "limited", "label": "limited beta", "description": "An active limited beta",
"started": "2023-07-19T15:23:43", "ended": null, "greenlight_only": false,
"more_info": "a link with even more info"}], "page": 1, "pages": 1, "results": 2}'
headers:
Access-Control-Allow-Credentials:
- "true"
Expand All @@ -29,8 +34,6 @@ interactions:
Cache-Control:
- private, max-age=0, s-maxage=0, no-cache, no-store
- private, max-age=60, s-maxage=60
Content-Length:
- "49"
Content-Security-Policy:
- default-src 'none'
Content-Type:
Expand All @@ -40,6 +43,7 @@ interactions:
Strict-Transport-Security:
- max-age=31536000
Vary:
- Accept-Encoding
- Authorization, X-Filter
- Authorization, X-Filter
X-Accepted-Oauth-Scopes:
Expand All @@ -52,7 +56,7 @@ interactions:
X-Oauth-Scopes:
- '*'
X-Ratelimit-Limit:
- "800"
- "1200"
X-Xss-Protection:
- 1; mode=block
status: 200 OK
Expand Down

0 comments on commit d22fb85

Please sign in to comment.