-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: separate unit tests from integration suite for cleaner practice (…
…#473) * separate unit tests from integration tests and edit the makefiles accordingly * address PR comment
- Loading branch information
Showing
15 changed files
with
74 additions
and
66 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
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
2 changes: 1 addition & 1 deletion
2
test/integration/account_transfer_test.go → test/unit/account_transfer_test.go
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 @@ | ||
package integration | ||
package unit | ||
|
||
import ( | ||
"context" | ||
|
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 @@ | ||
package integration | ||
package unit | ||
|
||
import ( | ||
"context" | ||
|
2 changes: 1 addition & 1 deletion
2
test/integration/instance_stats_test.go → test/unit/instance_stats_test.go
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 @@ | ||
package integration | ||
package unit | ||
|
||
import ( | ||
"context" | ||
|
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,35 @@ | ||
package unit | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/jarcoal/httpmock" | ||
"github.com/linode/linodego" | ||
) | ||
|
||
func TestLKECluster_Regenerate(t *testing.T) { | ||
client := createMockClient(t) | ||
|
||
requestData := linodego.LKEClusterRegenerateOptions{ | ||
KubeConfig: true, | ||
ServiceToken: false, | ||
} | ||
|
||
httpmock.RegisterRegexpResponder("POST", mockRequestURL(t, "clusters/1234/regenerate"), | ||
mockRequestBodyValidate(t, requestData, nil)) | ||
|
||
if _, err := client.RegenerateLKECluster(context.Background(), 1234, requestData); err != nil { | ||
t.Fatal(err) | ||
} | ||
} | ||
|
||
func TestLKECluster_DeleteServiceToken(t *testing.T) { | ||
client := createMockClient(t) | ||
|
||
httpmock.RegisterRegexpResponder("DELETE", mockRequestURL(t, "clusters/1234/servicetoken"), httpmock.NewStringResponder(200, "{}")) | ||
|
||
if err := client.DeleteLKEClusterServiceToken(context.Background(), 1234); err != nil { | ||
t.Fatal(err) | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
test/integration/profile_grants_list_test.go → test/unit/profile_grants_list_test.go
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 @@ | ||
package integration | ||
package unit | ||
|
||
import ( | ||
"context" | ||
|
2 changes: 1 addition & 1 deletion
2
.../integration/profile_phone_number_test.go → test/unit/profile_phone_number_test.go
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 @@ | ||
package integration | ||
package unit | ||
|
||
import ( | ||
"context" | ||
|
2 changes: 1 addition & 1 deletion
2
...ration/profile_security_questions_test.go → test/unit/profile_security_questions_test.go
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 @@ | ||
package integration | ||
package unit | ||
|
||
import ( | ||
"context" | ||
|
2 changes: 1 addition & 1 deletion
2
test/integration/profile_tfa_test.go → test/unit/profile_tfa_test.go
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 @@ | ||
package integration | ||
package unit | ||
|
||
import ( | ||
"context" | ||
|
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,22 @@ | ||
package unit | ||
|
||
import ( | ||
"github.com/linode/linodego" | ||
"github.com/linode/linodego/internal/testutil" | ||
"regexp" | ||
"testing" | ||
|
||
"github.com/jarcoal/httpmock" | ||
) | ||
|
||
func mockRequestBodyValidate(t *testing.T, expected interface{}, response interface{}) httpmock.Responder { | ||
return testutil.MockRequestBodyValidate(t, expected, response) | ||
} | ||
|
||
func mockRequestURL(t *testing.T, path string) *regexp.Regexp { | ||
return testutil.MockRequestURL(path) | ||
} | ||
|
||
func createMockClient(t *testing.T) *linodego.Client { | ||
return testutil.CreateMockClient(t, linodego.NewClient) | ||
} |