Skip to content
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

feat(exp): rename *utils package to *util #487

Merged
merged 2 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions hcloud/action_waiter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import (

"github.com/stretchr/testify/assert"

"github.com/hetznercloud/hcloud-go/v2/hcloud/exp/mockutils"
"github.com/hetznercloud/hcloud-go/v2/hcloud/exp/mockutil"
)

func TestWaitFor(t *testing.T) {
RunMockedTestCases(t,
[]MockedTestCase{
{
Name: "succeed",
WantRequests: []mockutils.Request{
WantRequests: []mockutil.Request{
{Method: "GET", Path: "/actions?id=1509772237&page=1&sort=status&sort=id",
Status: 200,
JSONRaw: `{
Expand Down Expand Up @@ -52,7 +52,7 @@ func TestWaitFor(t *testing.T) {
},
{
Name: "fail with unknown action",
WantRequests: []mockutils.Request{
WantRequests: []mockutil.Request{
{Method: "GET", Path: "/actions?id=1509772237&page=1&sort=status&sort=id",
Status: 200,
JSONRaw: `{
Expand Down Expand Up @@ -82,7 +82,7 @@ func TestWaitFor(t *testing.T) {
},
{
Name: "fail with server error",
WantRequests: []mockutils.Request{
WantRequests: []mockutil.Request{
{Method: "GET", Path: "/actions?id=1509772237&page=1&sort=status&sort=id",
Status: 500,
},
Expand All @@ -97,7 +97,7 @@ func TestWaitFor(t *testing.T) {
},
{
Name: "succeed with retry",
WantRequests: []mockutils.Request{
WantRequests: []mockutil.Request{
{Method: "GET", Path: "/actions?id=1509772237&page=1&sort=status&sort=id",
Status: 503,
},
Expand Down Expand Up @@ -127,7 +127,7 @@ func TestWaitForFunc(t *testing.T) {
[]MockedTestCase{
{
Name: "succeed",
WantRequests: []mockutils.Request{
WantRequests: []mockutil.Request{
{Method: "GET", Path: "/actions?id=1509772237&id=1509772238&page=1&sort=status&sort=id",
Status: 200,
JSONRaw: `{
Expand Down
2 changes: 1 addition & 1 deletion hcloud/exp/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Experimental

The [`exp`](./) namespace holds experimental features for the `hcloud-go` library. The [`exp/kit`](./kit/) namespace is reserved for features not directly related to the `hcloud-go` library, for example the [`sshutils`](./kit/sshutils) package has functions to generate ssh keys.
The [`exp`](./) namespace holds experimental features for the `hcloud-go` library. The [`exp/kit`](./kit/) namespace is reserved for features not directly related to the `hcloud-go` library, for example the [`sshutil`](./kit/sshutil) package has functions to generate ssh keys.

> [!CAUTION]
> Breaking changes may occur without notice. Do not use in production!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package actionutils
package actionutil

import "github.com/hetznercloud/hcloud-go/v2/hcloud"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package actionutils
package actionutil

import (
"testing"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package envutils
package envutil

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package envutils
package envutil

import (
"os"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sshutils
package sshutil

import (
"crypto"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sshutils
package sshutil

import (
"strings"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package labelutils
package labelutil

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package labelutils
package labelutil

import "testing"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mockutils
package mockutil

import (
"encoding/json"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mockutils
package mockutil

import (
"fmt"
Expand Down
6 changes: 3 additions & 3 deletions hcloud/mocked_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ import (
"net/http/httptest"
"testing"

"github.com/hetznercloud/hcloud-go/v2/hcloud/exp/mockutils"
"github.com/hetznercloud/hcloud-go/v2/hcloud/exp/mockutil"
)

type MockedTestCase struct {
Name string
WantRequests []mockutils.Request
WantRequests []mockutil.Request
Run func(env testEnv)
}

func RunMockedTestCases(t *testing.T, testCases []MockedTestCase) {
for _, testCase := range testCases {
t.Run(testCase.Name, func(t *testing.T) {
testServer := httptest.NewServer(mockutils.Handler(t, testCase.WantRequests))
testServer := httptest.NewServer(mockutil.Handler(t, testCase.WantRequests))

env := newTestEnvWithServer(testServer, nil)
defer env.Teardown()
Expand Down
Loading