Skip to content

Commit

Permalink
Add tostring override to postgre family name DU
Browse files Browse the repository at this point in the history
  • Loading branch information
VitorRigoni committed Aug 18, 2020
1 parent 38a5f1f commit 1b44cd0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
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"
}
]

0 comments on commit 1b44cd0

Please sign in to comment.