Skip to content

Commit

Permalink
remove omitempty for backup policy hour in DropletBackupPolicyRequest…
Browse files Browse the repository at this point in the history
… to be able to use zero as a value when encoding in client.NewRequest
  • Loading branch information
loosla committed Nov 1, 2024
1 parent 505a3d2 commit e886602
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion droplets.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ type DropletMultiCreateRequest struct {
type DropletBackupPolicyRequest struct {
Plan string `json:"plan,omitempty"`
Weekday string `json:"weekday,omitempty"`
Hour int `json:"hour,omitempty"`
Hour int `json:"hour"` // Avoid using omitempty to ensure zero values are included in the JSON output.
}

func (d DropletCreateRequest) String() string {
Expand Down
6 changes: 4 additions & 2 deletions droplets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,11 @@ func TestDroplets_Create(t *testing.T) {
},
Tags: []string{"one", "two"},
VPCUUID: "880b7f98-f062-404d-b33c-458d545696f6",
Backups: true,
BackupPolicy: &DropletBackupPolicyRequest{
Plan: "weekly",
Weekday: "MON",
Hour: 0,
},
}

Expand All @@ -334,7 +336,6 @@ func TestDroplets_Create(t *testing.T) {
"size": "size",
"image": float64(1),
"ssh_keys": nil,
"backups": false,
"ipv6": false,
"private_networking": false,
"monitoring": false,
Expand All @@ -344,7 +345,8 @@ func TestDroplets_Create(t *testing.T) {
},
"tags": []interface{}{"one", "two"},
"vpc_uuid": "880b7f98-f062-404d-b33c-458d545696f6",
"backup_policy": map[string]interface{}{"plan": "weekly", "weekday": "MON"},
"backups": true,
"backup_policy": map[string]interface{}{"plan": "weekly", "weekday": "MON", "hour": float64(0)},
}
jsonBlob := `
{
Expand Down

0 comments on commit e886602

Please sign in to comment.