-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add unit test coverage for Volume,Volume types and Longview related methods/functions #661
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
3a428a3
unit_tests
vshanthe 13271d0
add_test
vshanthe b4dbebc
Merge remote-tracking branch 'origin/main' into unit_test
vshanthe ea43a5a
database_tests
vshanthe 6173661
Merge remote-tracking branch 'origin/main' into unit_test
vshanthe 46309fc
volume_unittests
vshanthe 0bfa9fd
fix
vshanthe 348bcce
fix
vshanthe 0b0a046
Merge remote-tracking branch 'origin/main' into unit_test
vshanthe 23737b1
longview_tests
vshanthe 603269d
Merge remote-tracking branch 'origin/main' into unit_test
vshanthe e6c35fb
Merge branch 'main' into unit_test
vshanthe 6b079be
Merge branch 'main' into unit_test
vshanthe 808fe12
fix int_test
vshanthe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this skip required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that was causing error saying invalid token , but in the local it was passing so i added skip here