Skip to content

Commit

Permalink
PR Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
OilyLime committed Jul 11, 2024
1 parent 7c65898 commit 2eabbac
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 36 deletions.
32 changes: 16 additions & 16 deletions hyperdrive.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ type HyperdriveConfig struct {
type HyperdriveOriginType string

type HyperdriveConfigOrigin struct {
Database string `json:"database,omitempty"`
Host string `json:"host,omitempty"`
Port int `json:"port,omitempty"`
Scheme string `json:"scheme,omitempty"`
User string `json:"user,omitempty"`
AccessClientID string `json:"access_client_id,omitempty"`
AccessClientSecret string `json:"access_client_secret,omitempty"`
Database string `json:"database,omitempty"`
Host string `json:"host,omitempty"`
Port int `json:"port,omitempty"`
Scheme string `json:"scheme,omitempty"`
User string `json:"user,omitempty"`
AccessClientID string `json:"access_client_id,omitempty"`
}

type HyperdriveConfigOriginWithPassword struct {
type HyperdriveConfigOriginWithSecrets struct {
HyperdriveConfigOrigin
Password string `json:"password"`
Password string `json:"password"`
AccessClientSecret string `json:"access_client_secret,omitempty"`
}

type HyperdriveConfigCaching struct {
Expand All @@ -55,9 +55,9 @@ type HyperdriveConfigListResponse struct {
}

type CreateHyperdriveConfigParams struct {
Name string `json:"name"`
Origin HyperdriveConfigOriginWithPassword `json:"origin"`
Caching HyperdriveConfigCaching `json:"caching,omitempty"`
Name string `json:"name"`
Origin HyperdriveConfigOriginWithSecrets `json:"origin"`
Caching HyperdriveConfigCaching `json:"caching,omitempty"`
}

type HyperdriveConfigResponse struct {
Expand All @@ -66,10 +66,10 @@ type HyperdriveConfigResponse struct {
}

type UpdateHyperdriveConfigParams struct {
HyperdriveID string `json:"-"`
Name string `json:"name"`
Origin HyperdriveConfigOriginWithPassword `json:"origin"`
Caching HyperdriveConfigCaching `json:"caching,omitempty"`
HyperdriveID string `json:"-"`
Name string `json:"name"`
Origin HyperdriveConfigOriginWithSecrets `json:"origin"`
Caching HyperdriveConfigCaching `json:"caching,omitempty"`
}

type ListHyperdriveConfigParams struct{}
Expand Down
39 changes: 19 additions & 20 deletions hyperdrive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
const (
testHyperdriveConfigId = "6b7efc370ea34ded8327fa20698dfe3a"
testHyperdriveConfigName = "example-hyperdrive"
testAccessClientID = "1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a.access"
testAccessClientSecret = "1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a"
testAccessClientID = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.access"
testAccessClientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
)

func testHyperdriveHostAndPortConfig() HyperdriveConfig {
Expand All @@ -40,12 +40,11 @@ func testHyperdriveCFAccessConfig() HyperdriveConfig {
ID: testHyperdriveConfigId,
Name: testHyperdriveConfigName,
Origin: HyperdriveConfigOrigin{
Database: "postgres",
Host: "database.example.com",
Scheme: "postgres",
User: "postgres",
AccessClientID: testAccessClientID,
AccessClientSecret: testAccessClientSecret,
Database: "postgres",
Host: "database.example.com",
Scheme: "postgres",
User: "postgres",
AccessClientID: testAccessClientID,
},
Caching: HyperdriveConfigCaching{
Disabled: BoolPtr(false),
Expand Down Expand Up @@ -188,7 +187,7 @@ func TestHyperdriveConfig_CreateHostAndPort(t *testing.T) {

result, err := client.CreateHyperdriveConfig(context.Background(), AccountIdentifier(testAccountID), CreateHyperdriveConfigParams{
Name: "example-hyperdrive",
Origin: HyperdriveConfigOriginWithPassword{
Origin: HyperdriveConfigOriginWithSecrets{
HyperdriveConfigOrigin: HyperdriveConfigOrigin{
Database: "postgres",
Host: "database.example.com",
Expand Down Expand Up @@ -235,8 +234,8 @@ func TestHyperdriveConfig_CreateCFAccess(t *testing.T) {
"host": "database.example.com",
"scheme": "postgres",
"user": "postgres",
"access_client_id": "1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a.access",
"access_client_secret": "1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a"
"access_client_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.access",
"access_client_secret": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
}
}`)
Expand All @@ -254,16 +253,16 @@ func TestHyperdriveConfig_CreateCFAccess(t *testing.T) {

result, err := client.CreateHyperdriveConfig(context.Background(), AccountIdentifier(testAccountID), CreateHyperdriveConfigParams{
Name: "example-hyperdrive",
Origin: HyperdriveConfigOriginWithPassword{
Origin: HyperdriveConfigOriginWithSecrets{
HyperdriveConfigOrigin: HyperdriveConfigOrigin{
Database: "postgres",
Host: "database.example.com",
Scheme: "postgres",
User: "postgres",
AccessClientID: testAccessClientID,
AccessClientSecret: testAccessClientSecret,
Database: "postgres",
Host: "database.example.com",
Scheme: "postgres",
User: "postgres",
AccessClientID: testAccessClientID,
},
Password: "password",
Password: "password",
AccessClientSecret: testAccessClientSecret,
},
Caching: HyperdriveConfigCaching{
Disabled: BoolPtr(false),
Expand Down Expand Up @@ -350,7 +349,7 @@ func TestHyperdriveConfig_Update(t *testing.T) {
result, err := client.UpdateHyperdriveConfig(context.Background(), AccountIdentifier(testAccountID), UpdateHyperdriveConfigParams{
HyperdriveID: "6b7efc370ea34ded8327fa20698dfe3a",
Name: "example-hyperdrive",
Origin: HyperdriveConfigOriginWithPassword{
Origin: HyperdriveConfigOriginWithSecrets{
HyperdriveConfigOrigin: HyperdriveConfigOrigin{
Database: "postgres",
Host: "database.example.com",
Expand Down

0 comments on commit 2eabbac

Please sign in to comment.