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

Add tostring override to postgre family name DU #316

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
13 changes: 11 additions & 2 deletions src/Farmer/Arm/DBforPostgreSQL.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@ let databases = ResourceType "Microsoft.DBforPostgreSQL/servers/databases"
let firewallRules = ResourceType "Microsoft.DBforPostgreSQL/servers/firewallrules"
let servers = ResourceType "Microsoft.DBforPostgreSQL/servers"

type [<RequireQualifiedAccess>] PostgreSQLFamily = Gen5
type [<RequireQualifiedAccess>] PostgreSQLFamily =
| Gen5

override this.ToString() =
match this with
| Gen5 -> "Gen5"

member this.AsArmValue =
match this with
| Gen5 -> "Gen5"

module Servers =
type Database =
Expand Down Expand Up @@ -60,7 +69,7 @@ type Server =
BackupRetention : int<Days> }

member this.Sku =
{| name = sprintf "%s_%O_%d" this.Tier.Name this.Family this.Capacity
{| name = sprintf "%s_%s_%d" this.Tier.Name this.Family.AsArmValue this.Capacity
tier = string this.Tier
capacity = this.Capacity
family = string this.Family
Expand Down
6 changes: 6 additions & 0 deletions src/Tests/PostgreSQL.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ open Farmer
open Farmer.PostgreSQL
open Farmer.Builders
open Newtonsoft.Json.Linq
open Farmer.Arm

type PostgresSku =
{ name : string
Expand Down Expand Up @@ -266,4 +267,9 @@ let tests = testList "PostgreSQL Database Service" [
Expect.throws (fun () -> Validate.capacity 13<VCores>) "Capacity not a power of two"
Expect.throwsNot (fun () -> Validate.capacity 16<VCores>) "Capacity just right"
}

test "Family name should not include type name" {
Expect.equal PostgreSQLFamily.Gen5.AsArmValue "Gen5" "Wrong value for Gen5 family"
Expect.equal (PostgreSQLFamily.Gen5.ToString()) "Gen5" "Wrong value for Gen5 family"
}
]