Skip to content

Commit

Permalink
feat(exp): rename *utils package to *util (#487)
Browse files Browse the repository at this point in the history
Use a smaller and clearer package name.
  • Loading branch information
jooola committed Jul 19, 2024
1 parent f7ac563 commit 19da475
Show file tree
Hide file tree
Showing 13 changed files with 20 additions and 20 deletions.
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

0 comments on commit 19da475

Please sign in to comment.