Skip to content

Commit

Permalink
Merge pull request #429 from lefthandedgoat/master163
Browse files Browse the repository at this point in the history
Master163
  • Loading branch information
lefthandedgoat authored Apr 12, 2018
2 parents c815b58 + b0ab7e2 commit 0583724
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
1 change: 0 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,6 @@ Update to Selenium 3.3 [Issue #351](https://github.com/lefthandedgoat/canopy/iss
#### 1.6.3 - Mar 3 2018
* Protect from null refs in selector suggestions, thanks Haf! [Issue #404](https://github.com/lefthandedgoat/canopy/issues/404)
* Provide better error messages when the browser is null, thanks again Haf! [Issue #405](https://github.com/lefthandedgoat/canopy/issues/405)

#### 2.0.0-alpha - Mar 25 2018
* Alpha release, some breaking changes with open statements, not yet documented, no migration docs yet
* Added parallel support, thanks @haf!
Expand Down
2 changes: 1 addition & 1 deletion src/canopy.integration/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ module internal AssemblyVersionInformation =
let [<Literal>] AssemblyProduct = "canopy.integration"
let [<Literal>] AssemblyDescription = "F# web testing framework"
let [<Literal>] AssemblyVersion = "2.0.0"
let [<Literal>] AssemblyFileVersion = "2.0.0"
let [<Literal>] AssemblyFileVersion = "2.0.0"
13 changes: 12 additions & 1 deletion src/canopy.integration/jsonValidator.fs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ let AST jsonValue =
| Property -> sprintf "%s.%s" self.Path prop
| _ -> failwith (sprintf "should not happen %A" type')

AST { self with Path = path; Name = prop; ParentPath = self.Path; Type = type'; ParentType = self.Type; ImmediateOptional = false } value
AST { self with Path = path; Name = prop; ParentPath = self.Path; Type = type'; ParentType = self.Type; ImmediateOptional = false; HistoricalOptional = true } value
)
|> Array.concat
|> Array.append [| self |]
Expand Down Expand Up @@ -110,6 +110,17 @@ let diff example actual =
if exists then asProperty else meta
else meta)
|> Set.ofSeq

//if there is a null in actual and it has a matching record value in example, replace with the record definition because null records are legit
let actual =
actual
|> Seq.map (fun meta ->
if meta.Type = Type.Null then
let asRecord = { meta with Type = Record; Path = meta.Path.Replace(meta.Name, sprintf "{%s}" meta.Name) }
let exists = example.Contains(asRecord)
if exists then asRecord else meta
else meta)
|> Set.ofSeq

let missing =
let allMissing =
Expand Down
1 change: 1 addition & 0 deletions src/canopy/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ open System.Reflection
[<assembly: AssemblyDescriptionAttribute("F# web testing framework")>]
[<assembly: AssemblyVersionAttribute("2.0.0")>]
[<assembly: AssemblyFileVersionAttribute("2.0.0")>]

do ()

module internal AssemblyVersionInformation =
Expand Down
8 changes: 6 additions & 2 deletions tests/basictests/jsonValidatorTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ let location8 = """{ "lat":4.0212, "long":12.102012, "people":[ { "first":"jane"

let class1 = """{ "name":"bio 101", "building":"science", "location": { "lat":4.0212, "long":12.102012, "people": [ { "first":"jane", "middle":"something", "last":"doe" } ] } }"""
let class2 = """{ "name":"chem 101", "building":"science", "location": { "lat":4.0212, "lng":12.102012, "people": [ { "first":"jane", "last":"doe" } ] } }"""
let class3 = """{ "name":"chem 101", "building":"science", "location": null }"""

let withArray = """{ "name":"bio 101", "people": [ { "first":"jane" } ] }"""
let nullArray = """{ "name":"chem 101", "people": null }"""
Expand Down Expand Up @@ -70,12 +71,15 @@ let all () =
"nested objects with arrays reocgnized correctly" &&& fun _ ->
diff class1 class2 ==
[
Missing "{root}.{location}.long"
Missing "{root}.{location}.[people].{}.middle"

Missing "{root}.{location}.long"

Extra "{root}.{location}.lng"
]

"null object property is ok" &&& fun _ ->
diff class1 class3 == [ ]

"null array is acceptable" &&& fun _ ->
diff withArray nullArray == [ ]

Expand Down

0 comments on commit 0583724

Please sign in to comment.