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

Use float64 for Server Template Instance/License cost #98

Merged
merged 1 commit into from
Aug 29, 2023
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 servers.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,16 @@ type ServerPlatformTemplates struct {

// ServerTemplateInstanceCost
type ServerTemplateInstanceCost struct {
Amount int `json:"amount"`
Currency string `json:"currency"`
Timeperiod string `json:"timeperiod"`
Amount float64 `json:"amount"`
Currency string `json:"currency"`
Timeperiod string `json:"timeperiod"`
}

// ServerTemplateLicenseCost
type ServerTemplateLicenseCost struct {
Amount int `json:"amount"`
Currency string `json:"currency"`
Timeperiod string `json:"timeperiod"`
Amount float64 `json:"amount"`
Currency string `json:"currency"`
Timeperiod string `json:"timeperiod"`
}

// ServerPlatformTemplateDetails represents a supported template.
Expand Down
11 changes: 9 additions & 2 deletions servers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,11 @@ func TestServersTemplates(t *testing.T) {
"licensecost": {"amount": 0, "currency": "SEK", "timeperiod": "month"}, "bootstrapmethod": "DEPLOY_SCRIPT"},
{"id": "dbbca8a7-1e26-4b76-8bb4-8d56dae59039", "name": "Alma Linux 9", "minimumdisksize": 5, "minimummemorysize": 512,
"operatingsystem": "linux", "platform": "VMware", "instancecost": {"amount": 0, "currency": "SEK", "timeperiod": "month"},
"licensecost": {"amount": 0, "currency": "SEK", "timeperiod": "month"}, "bootstrapmethod": "CLOUD_INIT"}]}}}`}
"licensecost": {"amount": 0, "currency": "SEK", "timeperiod": "month"}, "bootstrapmethod": "CLOUD_INIT"},
{"id": "d924551c-0a0d-43ba-abcd-aoeuqwer1234", "name": "Windows Server 2022 Standard LTSC", "minimumdisksize": 30,
"minimummemorysize": 1024, "operatingsystem": "windows", "platform": "VMware", "instancecost":
{"amount": 999.10, "currency": "SEK", "timeperiod": "month"}, "licensecost": {"amount": 123.4, "currency": "SEK",
"timeperiod": "month"}, "bootstrapmethod": "DEPLOY_SCRIPT"}]}}}`}
s := ServerService{client: c}

templates, _ := s.Templates(context.Background())
Expand All @@ -243,8 +247,11 @@ func TestServersTemplates(t *testing.T) {
assert.Equal(t, "CLOUD_INIT", templates.KVM[0].BootstrapMethod, "template bootstrapmethod is correct")
assert.Equal(t, "Alma Linux 8", templates.VMware[0].Name, "template name is correct")
assert.Equal(t, "DEPLOY_SCRIPT", templates.VMware[0].BootstrapMethod, "template bootstrapmethod is correct")
assert.Equal(t, 0, templates.VMware[0].LicenseCost.Amount, "template licensecost amount is correct")
assert.Equal(t, 0.0, templates.VMware[0].LicenseCost.Amount, "template licensecost amount is correct")
assert.Equal(t, "month", templates.VMware[0].LicenseCost.Timeperiod, "template licensecost timeperiod is correct")
assert.Equal(t, 999.1, templates.VMware[2].InstanceCost.Amount, "template instancecost amount is correct")
assert.Equal(t, 123.4, templates.VMware[2].LicenseCost.Amount, "template licensecost amount is correct")
assert.Equal(t, "month", templates.VMware[2].LicenseCost.Timeperiod, "template licensecost timeperiod is correct")
}

func TestGenerateHostnameReturnsAHostnameInTheCorrectFormat(t *testing.T) {
Expand Down