Skip to content

Commit

Permalink
Switch from new() to Pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
momer committed May 15, 2024
1 parent 285872e commit ce4bab3
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 deletions.
5 changes: 5 additions & 0 deletions bonsai/bonsai_impl_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package bonsai

func Pointer[T any](d T) *T {
return &d
}
4 changes: 0 additions & 4 deletions bonsai/bonsai_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ import (
"path/filepath"
)

func Pointer[T any](d T) *T {
return &d
}

func init() {
initLogger()
}
Expand Down
4 changes: 2 additions & 2 deletions bonsai/plan_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ func (s *ClientImplTestSuite) TestPlanAllResponseJsonUnmarshal() {
Name: "Sandbox",
PriceInCents: 0,
BillingIntervalInMonths: 1,
SingleTenant: new(bool),
PrivateNetwork: new(bool),
SingleTenant: Pointer(false),
PrivateNetwork: Pointer(false),
AvailableReleases: []string{
"elasticsearch-7.2.0",
},
Expand Down
12 changes: 6 additions & 6 deletions bonsai/plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ func (s *ClientMockTestSuite) TestPlanClient_All() {
Name: "Sandbox",
PriceInCents: 0,
BillingIntervalInMonths: 1,
SingleTenant: new(bool),
PrivateNetwork: new(bool),
SingleTenant: bonsai.Pointer(false),
PrivateNetwork: bonsai.Pointer(false),
AvailableReleases: []bonsai.Release{
// TODO: we'll see whether the response is actually a
// shortened version like this or a slug
Expand All @@ -92,8 +92,8 @@ func (s *ClientMockTestSuite) TestPlanClient_All() {
Name: "Standard Small",
PriceInCents: 5000,
BillingIntervalInMonths: 1,
SingleTenant: Pointer(false),
PrivateNetwork: Pointer(false),
SingleTenant: bonsai.Pointer(false),
PrivateNetwork: bonsai.Pointer(false),
AvailableReleases: []bonsai.Release{
{Slug: "elasticsearch-5.6.16"},
{Slug: "elasticsearch-6.8.3"},
Expand Down Expand Up @@ -155,8 +155,8 @@ func (s *ClientMockTestSuite) TestPlanClient_GetByPath() {
Name: "Sandbox",
PriceInCents: 0,
BillingIntervalInMonths: 1,
SingleTenant: new(bool),
PrivateNetwork: new(bool),
SingleTenant: bonsai.Pointer(false),
PrivateNetwork: bonsai.Pointer(false),
AvailableReleases: []bonsai.Release{
{Slug: "elasticsearch-7.2.0"},
},
Expand Down
8 changes: 4 additions & 4 deletions bonsai/release_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,21 @@ func (s *ClientMockTestSuite) TestReleaseClient_All() {
Slug: "elasticsearch-5.6.16",
ServiceType: "elasticsearch",
Version: "5.6.16",
MultiTenant: Pointer(true),
MultiTenant: bonsai.Pointer(true),
},
{
Name: "Elasticsearch 6.5.4",
Slug: "elasticsearch-6.5.4",
ServiceType: "elasticsearch",
Version: "6.5.4",
MultiTenant: Pointer(true),
MultiTenant: bonsai.Pointer(true),
},
{
Name: "Elasticsearch 7.2.0",
Slug: "elasticsearch-7.2.0",
ServiceType: "elasticsearch",
Version: "7.2.0",
MultiTenant: Pointer(true),
MultiTenant: bonsai.Pointer(true),
},
}
releases, err := s.client.Release.All(context.Background())
Expand Down Expand Up @@ -108,7 +108,7 @@ func (s *ClientMockTestSuite) TestReleaseClient_GetBySlug() {
Name: "Elasticsearch 7.2.0",
ServiceType: "elasticsearch",
Version: "7.2.0",
MultiTenant: Pointer(true),
MultiTenant: bonsai.Pointer(true),
}

resultResp, err := s.client.Release.GetBySlug(context.Background(), targetReleaseSlug)
Expand Down
2 changes: 1 addition & 1 deletion bonsai/space_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (s *ClientMockTestSuite) TestSpaceClient_GetByPath() {
s.NoError(err, "successfully get space by path")

s.Equal(targetSpacePath, space.Path)
s.Equal(new(bool), space.PrivateNetwork)
s.Equal(bonsai.Pointer(false), space.PrivateNetwork)
s.Equal("aws", space.Cloud.Provider)
s.Equal("aws-us-east-1", space.Cloud.Region)
}
Expand Down

0 comments on commit ce4bab3

Please sign in to comment.