-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit test coverage for Volume,Volume types and Longview related m…
…ethods/functions (#661) * unit_tests * add_test * database_tests * volume_unittests * fix * fix * longview_tests * fix int_test
- Loading branch information
Showing
19 changed files
with
606 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,6 @@ require ( | |
|
||
replace github.com/linode/linodego => ../ | ||
|
||
go 1.22 | ||
go 1.22.0 | ||
|
||
toolchain go1.22.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"id": 123, | ||
"label": "apache_client", | ||
"api_key": "API_KEY_123", | ||
"install_code": "install_code_123", | ||
"apps": { | ||
"apache": {}, | ||
"mysql": {}, | ||
"nginx": {} | ||
}, | ||
"created": "2025-01-23T00:00:00", | ||
"updated": "2025-01-23T00:00:00" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"data": [ | ||
{ | ||
"id": 123, | ||
"label": "apache_client", | ||
"api_key": "API_KEY_123", | ||
"install_code": "install_code_123", | ||
"apps": { | ||
"apache": {}, | ||
"mysql": {}, | ||
"nginx": {} | ||
}, | ||
"created": "2025-01-23T00:00:00", | ||
"updated": "2025-01-23T00:00:00" | ||
}, | ||
{ | ||
"id": 124, | ||
"label": "mysql_client", | ||
"api_key": "API_KEY_124", | ||
"install_code": "install_code_124", | ||
"apps": { | ||
"apache": {}, | ||
"mysql": {}, | ||
"nginx": {} | ||
}, | ||
"created": "2025-01-23T00:00:00", | ||
"updated": "2025-01-23T00:00:00" | ||
} | ||
], | ||
"pages": 1, | ||
"results": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"id": "longview-plan-id", | ||
"label": "Longview Plan", | ||
"clients_included": 5, | ||
"price": { | ||
"hourly": 50.00, | ||
"monthly": 500.00 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"id": "longview-1", | ||
"label": "Longview Pro", | ||
"clients_included": 3, | ||
"price": { | ||
"hourly": 0.01, | ||
"monthly": 10.00 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"data": [ | ||
{ | ||
"id": "longview-1", | ||
"label": "Longview Pro", | ||
"clients_included": 3, | ||
"price": { | ||
"hourly": 0.01, | ||
"monthly": 10.00 | ||
} | ||
}, | ||
{ | ||
"id": "longview-2", | ||
"label": "Longview Enterprise", | ||
"clients_included": 10, | ||
"price": { | ||
"hourly": 0.05, | ||
"monthly": 50.00 | ||
} | ||
} | ||
], | ||
"pages": 1, | ||
"results": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"id": 123, | ||
"label": "Test Volume", | ||
"status": "active", | ||
"region": "us-east", | ||
"size": 20, | ||
"linode_id": 456, | ||
"filesystem_path": "/dev/disk/by-id/volume-123", | ||
"tags": ["test"], | ||
"hardware_type": "", | ||
"linode_label": "linode-test", | ||
"encryption": "", | ||
"created": "2025-01-01T12:00:00", | ||
"updated": "2025-01-20T12:00:00" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"id": 124, | ||
"label": "new-volume", | ||
"status": "creating", | ||
"region": "us-east", | ||
"size": 20, | ||
"linode_id": null, | ||
"filesystem_path": "", | ||
"tags": ["test"], | ||
"hardware_type": "", | ||
"linode_label": "", | ||
"encryption": "", | ||
"created": "2025-01-15T12:00:00", | ||
"updated": "2025-01-15T12:00:00" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"id": 123, | ||
"label": "Test Volume", | ||
"status": "active", | ||
"region": "us-east", | ||
"size": 20, | ||
"linode_id": null, | ||
"filesystem_path": "", | ||
"tags": ["test"], | ||
"hardware_type": "", | ||
"linode_label": "", | ||
"encryption": "", | ||
"created": "2025-01-01T12:00:00", | ||
"updated": "2025-01-10T12:00:00" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"data": [ | ||
{ | ||
"id": "standard", | ||
"label": "Standard Volume", | ||
"price": { | ||
"hourly": 0.10, | ||
"monthly": 10.00 | ||
}, | ||
"region_prices": [ | ||
{ | ||
"region": "us-east", | ||
"hourly": 0.08, | ||
"monthly": 8.00 | ||
} | ||
] | ||
}, | ||
{ | ||
"id": "high-performance", | ||
"label": "High Performance Volume", | ||
"price": { | ||
"hourly": 0.20, | ||
"monthly": 20.00 | ||
}, | ||
"region_prices": [ | ||
{ | ||
"region": "us-east", | ||
"hourly": 0.18, | ||
"monthly": 18.00 | ||
} | ||
] | ||
} | ||
], | ||
"pages": 1, | ||
"results": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"id": 123, | ||
"label": "updated-volume", | ||
"status": "active", | ||
"region": "us-east", | ||
"size": 20, | ||
"linode_id": null, | ||
"filesystem_path": "", | ||
"tags": ["updated"], | ||
"hardware_type": "", | ||
"linode_label": "", | ||
"encryption": "", | ||
"created": "2025-01-01T12:00:00", | ||
"updated": "2025-01-18T12:00:00" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"data": [ | ||
{ | ||
"id": 123, | ||
"label": "Test Volume", | ||
"status": "active", | ||
"region": "us-east", | ||
"size": 20, | ||
"linode_id": null, | ||
"filesystem_path": "", | ||
"tags": ["test"], | ||
"hardware_type": "", | ||
"linode_label": "", | ||
"encryption": "", | ||
"created": "2025-01-01T12:00:00", | ||
"updated": "2025-01-10T12:00:00" | ||
} | ||
] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package unit | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/linode/linodego" | ||
) | ||
|
||
func TestListLongviewSubscriptions(t *testing.T) { | ||
// Load the mock fixture for Longview subscriptions | ||
fixtureData, err := fixtures.GetFixture("longview_subscriptions_list") | ||
assert.NoError(t, err, "Expected no error when getting fixture") | ||
|
||
var base ClientBaseCase | ||
base.SetUp(t) | ||
defer base.TearDown(t) | ||
|
||
// Mock the GET request for the Longview subscriptions endpoint | ||
base.MockGet("longview/subscriptions", fixtureData) | ||
|
||
// Call the ListLongviewSubscriptions method | ||
subscriptions, err := base.Client.ListLongviewSubscriptions(context.Background(), &linodego.ListOptions{}) | ||
assert.NoError(t, err, "Expected no error when listing Longview subscriptions") | ||
assert.NotEmpty(t, subscriptions, "Expected non-empty Longview subscriptions list") | ||
|
||
// Validate the first subscription's details | ||
assert.Equal(t, "longview-1", subscriptions[0].ID, "Expected subscription ID to match") | ||
assert.Equal(t, "Longview Pro", subscriptions[0].Label, "Expected subscription label to match") | ||
assert.Equal(t, 3, subscriptions[0].ClientsIncluded, "Expected clients included to match") | ||
assert.NotNil(t, subscriptions[0].Price, "Expected price to be non-nil") | ||
assert.Equal(t, float32(10.00), subscriptions[0].Price.Monthly, "Expected monthly price to match") | ||
assert.Equal(t, float32(0.01), subscriptions[0].Price.Hourly, "Expected hourly price to match") | ||
} | ||
|
||
func TestGetLongviewSubscription(t *testing.T) { | ||
// Load the mock fixture for a single Longview subscription | ||
fixtureData, err := fixtures.GetFixture("longview_subscription_get") | ||
assert.NoError(t, err, "Expected no error when getting fixture") | ||
|
||
var base ClientBaseCase | ||
base.SetUp(t) | ||
defer base.TearDown(t) | ||
|
||
// Mock the GET request for a single Longview subscription | ||
subscriptionID := "longview-1" | ||
base.MockGet("longview/subscriptions/"+subscriptionID, fixtureData) | ||
|
||
// Call the GetLongviewSubscription method | ||
subscription, err := base.Client.GetLongviewSubscription(context.Background(), subscriptionID) | ||
assert.NoError(t, err, "Expected no error when getting Longview subscription") | ||
assert.NotNil(t, subscription, "Expected non-nil Longview subscription") | ||
|
||
// Validate the subscription's details | ||
assert.Equal(t, "longview-1", subscription.ID, "Expected subscription ID to match") | ||
assert.Equal(t, "Longview Pro", subscription.Label, "Expected subscription label to match") | ||
assert.Equal(t, 3, subscription.ClientsIncluded, "Expected clients included to match") | ||
assert.NotNil(t, subscription.Price, "Expected price to be non-nil") | ||
assert.Equal(t, float32(10.00), subscription.Price.Monthly, "Expected monthly price to match") | ||
assert.Equal(t, float32(0.01), subscription.Price.Hourly, "Expected hourly price to match") | ||
} |
Oops, something went wrong.