-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Bump Golang to 1.22 * Apply for loop breaking changes for Go 1.22 * gofumpt
- Loading branch information
1 parent
3203901
commit 23902e3
Showing
15 changed files
with
176 additions
and
177 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,6 @@ require ( | |
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
) | ||
|
||
go 1.21 | ||
go 1.22 | ||
|
||
retract v1.0.0 // Accidental branch push |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
go 1.21 | ||
go 1.22 | ||
|
||
use ( | ||
. | ||
|
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 |
---|---|---|
|
@@ -49,4 +49,4 @@ require ( | |
|
||
replace github.com/linode/linodego => ../ | ||
|
||
go 1.21 | ||
go 1.22 |
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 |
---|---|---|
@@ -1,44 +1,44 @@ | ||
package integration | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
"context" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestInvoice_List(t *testing.T) { | ||
warnSensitiveTest(t) | ||
client, teardown := createTestClient(t, "fixtures/TestInvoice_List") | ||
defer teardown() | ||
warnSensitiveTest(t) | ||
client, teardown := createTestClient(t, "fixtures/TestInvoice_List") | ||
defer teardown() | ||
|
||
invoices, err := client.ListInvoices(context.Background(), nil) | ||
require.NoError(t, err, "Error getting Invoices, expected struct") | ||
require.NotEmpty(t, invoices, "Expected to see invoices returned") | ||
invoices, err := client.ListInvoices(context.Background(), nil) | ||
require.NoError(t, err, "Error getting Invoices, expected struct") | ||
require.NotEmpty(t, invoices, "Expected to see invoices returned") | ||
} | ||
|
||
func TestInvoice_Get(t *testing.T) { | ||
warnSensitiveTest(t) | ||
client, teardown := createTestClient(t, "fixtures/TestInvoice_Get") | ||
defer teardown() | ||
|
||
invoice, err := client.GetInvoice(context.Background(), 123) | ||
require.NoError(t, err, "Error getting Invoice, expected struct") | ||
require.Equal(t, 123, invoice.ID, "Expected Invoice ID to be 123") | ||
require.Equal(t, "Invoice", invoice.Label, "Expected Invoice Label to be 'Invoice'") | ||
require.Equal(t, 132.5, float64(invoice.Total), "Expected Invoice Total to be 132.5") | ||
warnSensitiveTest(t) | ||
client, teardown := createTestClient(t, "fixtures/TestInvoice_Get") | ||
defer teardown() | ||
|
||
invoice, err := client.GetInvoice(context.Background(), 123) | ||
require.NoError(t, err, "Error getting Invoice, expected struct") | ||
require.Equal(t, 123, invoice.ID, "Expected Invoice ID to be 123") | ||
require.Equal(t, "Invoice", invoice.Label, "Expected Invoice Label to be 'Invoice'") | ||
require.Equal(t, 132.5, float64(invoice.Total), "Expected Invoice Total to be 132.5") | ||
} | ||
|
||
func TestInvoiceItems_List(t *testing.T) { | ||
warnSensitiveTest(t) | ||
client, teardown := createTestClient(t, "fixtures/TestInvoiceItems_List") | ||
defer teardown() | ||
|
||
items, err := client.ListInvoiceItems(context.Background(), 123, nil) | ||
require.NoError(t, err, "Error getting Invoice Items, expected struct") | ||
require.NotEmpty(t, items, "Expected to see invoice items returned") | ||
|
||
item := items[0] | ||
require.Equal(t, "Linode 2GB", item.Label, "Expected item label to be 'Linode 2GB'") | ||
require.Equal(t, 10.0, float64(item.Amount), "Expected item amount to be 10") | ||
} | ||
warnSensitiveTest(t) | ||
client, teardown := createTestClient(t, "fixtures/TestInvoiceItems_List") | ||
defer teardown() | ||
|
||
items, err := client.ListInvoiceItems(context.Background(), 123, nil) | ||
require.NoError(t, err, "Error getting Invoice Items, expected struct") | ||
require.NotEmpty(t, items, "Expected to see invoice items returned") | ||
|
||
item := items[0] | ||
require.Equal(t, "Linode 2GB", item.Label, "Expected item label to be 'Linode 2GB'") | ||
require.Equal(t, 10.0, float64(item.Amount), "Expected item amount to be 10") | ||
} |
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 |
---|---|---|
@@ -1,79 +1,79 @@ | ||
package integration | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"testing" | ||
"context" | ||
"encoding/json" | ||
"testing" | ||
|
||
"github.com/jarcoal/httpmock" | ||
"github.com/linode/linodego" | ||
"github.com/stretchr/testify/require" | ||
"github.com/jarcoal/httpmock" | ||
"github.com/linode/linodego" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestAccountSettings_Get(t *testing.T) { | ||
client, teardown := createTestClient(t, "fixtures/TestAccountSettings") | ||
defer teardown() | ||
|
||
// Mocking the API response | ||
httpmock.Activate() | ||
defer httpmock.DeactivateAndReset() | ||
|
||
mockSettings := linodego.AccountSettings{ | ||
BackupsEnabled: true, | ||
Managed: true, | ||
NetworkHelper: true, | ||
LongviewSubscription: String("longview-3"), | ||
ObjectStorage: String("active"), | ||
} | ||
mockResponse, _ := json.Marshal(mockSettings) | ||
|
||
httpmock.RegisterResponder("GET", "https://api.linode.com/v4/account/settings", | ||
httpmock.NewStringResponder(200, string(mockResponse))) | ||
|
||
settings, err := client.GetAccountSettings(context.Background()) | ||
require.NoError(t, err, "Error getting Account Settings") | ||
|
||
require.True(t, settings.BackupsEnabled, "Expected BackupsEnabled to be true") | ||
require.True(t, settings.Managed, "Expected Managed to be true") | ||
require.True(t, settings.NetworkHelper, "Expected NetworkHelper to be true") | ||
require.NotNil(t, settings.LongviewSubscription, "Expected LongviewSubscription to be non-nil") | ||
require.Equal(t, "longview-3", *settings.LongviewSubscription, "Expected LongviewSubscription to be 'longview-3'") | ||
require.NotNil(t, settings.ObjectStorage, "Expected ObjectStorage to be non-nil") | ||
require.Equal(t, "active", *settings.ObjectStorage, "Expected ObjectStorage to be 'active'") | ||
client, teardown := createTestClient(t, "fixtures/TestAccountSettings") | ||
defer teardown() | ||
|
||
// Mocking the API response | ||
httpmock.Activate() | ||
defer httpmock.DeactivateAndReset() | ||
|
||
mockSettings := linodego.AccountSettings{ | ||
BackupsEnabled: true, | ||
Managed: true, | ||
NetworkHelper: true, | ||
LongviewSubscription: String("longview-3"), | ||
ObjectStorage: String("active"), | ||
} | ||
mockResponse, _ := json.Marshal(mockSettings) | ||
|
||
httpmock.RegisterResponder("GET", "https://api.linode.com/v4/account/settings", | ||
httpmock.NewStringResponder(200, string(mockResponse))) | ||
|
||
settings, err := client.GetAccountSettings(context.Background()) | ||
require.NoError(t, err, "Error getting Account Settings") | ||
|
||
require.True(t, settings.BackupsEnabled, "Expected BackupsEnabled to be true") | ||
require.True(t, settings.Managed, "Expected Managed to be true") | ||
require.True(t, settings.NetworkHelper, "Expected NetworkHelper to be true") | ||
require.NotNil(t, settings.LongviewSubscription, "Expected LongviewSubscription to be non-nil") | ||
require.Equal(t, "longview-3", *settings.LongviewSubscription, "Expected LongviewSubscription to be 'longview-3'") | ||
require.NotNil(t, settings.ObjectStorage, "Expected ObjectStorage to be non-nil") | ||
require.Equal(t, "active", *settings.ObjectStorage, "Expected ObjectStorage to be 'active'") | ||
} | ||
|
||
func TestAccountSettings_Update(t *testing.T) { | ||
client, teardown := createTestClient(t, "fixtures/TestAccountSettings") | ||
defer teardown() | ||
|
||
// Mocking the API response | ||
httpmock.Activate() | ||
defer httpmock.DeactivateAndReset() | ||
|
||
opts := linodego.AccountSettingsUpdateOptions{ | ||
BackupsEnabled: Bool(false), | ||
LongviewSubscription: String("longview-10"), | ||
NetworkHelper: Bool(false), | ||
} | ||
|
||
mockSettings := linodego.AccountSettings{ | ||
BackupsEnabled: false, | ||
NetworkHelper: false, | ||
LongviewSubscription: String("longview-10"), | ||
} | ||
mockResponse, _ := json.Marshal(mockSettings) | ||
|
||
httpmock.RegisterResponder("PUT", "https://api.linode.com/v4/account/settings", | ||
httpmock.NewStringResponder(200, string(mockResponse))) | ||
|
||
settings, err := client.UpdateAccountSettings(context.Background(), opts) | ||
require.NoError(t, err, "Error updating Account Settings") | ||
|
||
require.False(t, settings.BackupsEnabled, "Expected BackupsEnabled to be false") | ||
require.False(t, settings.NetworkHelper, "Expected NetworkHelper to be false") | ||
require.NotNil(t, settings.LongviewSubscription, "Expected LongviewSubscription to be non-nil") | ||
require.Equal(t, "longview-10", *settings.LongviewSubscription, "Expected LongviewSubscription to be 'longview-10'") | ||
client, teardown := createTestClient(t, "fixtures/TestAccountSettings") | ||
defer teardown() | ||
|
||
// Mocking the API response | ||
httpmock.Activate() | ||
defer httpmock.DeactivateAndReset() | ||
|
||
opts := linodego.AccountSettingsUpdateOptions{ | ||
BackupsEnabled: Bool(false), | ||
LongviewSubscription: String("longview-10"), | ||
NetworkHelper: Bool(false), | ||
} | ||
|
||
mockSettings := linodego.AccountSettings{ | ||
BackupsEnabled: false, | ||
NetworkHelper: false, | ||
LongviewSubscription: String("longview-10"), | ||
} | ||
mockResponse, _ := json.Marshal(mockSettings) | ||
|
||
httpmock.RegisterResponder("PUT", "https://api.linode.com/v4/account/settings", | ||
httpmock.NewStringResponder(200, string(mockResponse))) | ||
|
||
settings, err := client.UpdateAccountSettings(context.Background(), opts) | ||
require.NoError(t, err, "Error updating Account Settings") | ||
|
||
require.False(t, settings.BackupsEnabled, "Expected BackupsEnabled to be false") | ||
require.False(t, settings.NetworkHelper, "Expected NetworkHelper to be false") | ||
require.NotNil(t, settings.LongviewSubscription, "Expected LongviewSubscription to be non-nil") | ||
require.Equal(t, "longview-10", *settings.LongviewSubscription, "Expected LongviewSubscription to be 'longview-10'") | ||
} | ||
|
||
func Bool(v bool) *bool { return &v } | ||
func String(v string) *string { return &v } | ||
func Bool(v bool) *bool { return &v } | ||
func String(v string) *string { return &v } |
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 |
---|---|---|
@@ -1,29 +1,29 @@ | ||
package integration | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
"context" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestAccountTransfer_Get(t *testing.T) { | ||
client, teardown := createTestClient(t, "fixtures/TestAccountTransfer_Get") | ||
defer teardown() | ||
client, teardown := createTestClient(t, "fixtures/TestAccountTransfer_Get") | ||
defer teardown() | ||
|
||
transfer, err := client.GetAccountTransfer(context.Background()) | ||
require.NoError(t, err, "Error getting Account Transfer, expected struct") | ||
transfer, err := client.GetAccountTransfer(context.Background()) | ||
require.NoError(t, err, "Error getting Account Transfer, expected struct") | ||
|
||
require.NotEqual(t, 0, transfer.Billable, "Expected non-zero value for Billable") | ||
require.NotEqual(t, 0, transfer.Quota, "Expected non-zero value for Quota") | ||
require.NotEqual(t, 0, transfer.Used, "Expected non-zero value for Used") | ||
require.NotEqual(t, 0, transfer.Billable, "Expected non-zero value for Billable") | ||
require.NotEqual(t, 0, transfer.Quota, "Expected non-zero value for Quota") | ||
require.NotEqual(t, 0, transfer.Used, "Expected non-zero value for Used") | ||
|
||
require.NotEmpty(t, transfer.RegionTransfers, "Expected to see region transfers") | ||
require.NotEmpty(t, transfer.RegionTransfers, "Expected to see region transfers") | ||
|
||
for _, regionTransfer := range transfer.RegionTransfers { | ||
require.NotEmpty(t, regionTransfer.ID, "Expected region ID to be non-empty") | ||
require.NotEqual(t, 0, regionTransfer.Billable, "Expected non-zero value for Billable in region %s", regionTransfer.ID) | ||
require.NotEqual(t, 0, regionTransfer.Quota, "Expected non-zero value for Quota in region %s", regionTransfer.ID) | ||
require.NotEqual(t, 0, regionTransfer.Used, "Expected non-zero value for Used in region %s", regionTransfer.ID) | ||
} | ||
} | ||
for _, regionTransfer := range transfer.RegionTransfers { | ||
require.NotEmpty(t, regionTransfer.ID, "Expected region ID to be non-empty") | ||
require.NotEqual(t, 0, regionTransfer.Billable, "Expected non-zero value for Billable in region %s", regionTransfer.ID) | ||
require.NotEqual(t, 0, regionTransfer.Quota, "Expected non-zero value for Quota in region %s", regionTransfer.ID) | ||
require.NotEqual(t, 0, regionTransfer.Used, "Expected non-zero value for Used in region %s", regionTransfer.ID) | ||
} | ||
} |
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
Oops, something went wrong.