Skip to content

Commit

Permalink
add test with only package restriction
Browse files Browse the repository at this point in the history
  • Loading branch information
enricosada committed Aug 15, 2018
1 parent be633b7 commit 67b1422
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/Paket.Tests/InstallModel/PaketPropsTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,40 @@ group Other2
|> checkContainsPackageRefs [ "FsCheck","2.8.2" ]
| l ->
Assert.Fail(sprintf "expected three ItemGroup but was '%A'" l)

[<Test>]
let ``should create props file for design mode package restriction``() =

let lockFile = """NUGET
remote: https://api.nuget.org/v3/index.json
Newtonsoft.Json (11.0.2) - restriction: == netcoreapp2.1
"""

let refFileContent = """
Newtonsoft.Json
"""

let lockFile = LockFile.Parse("", toLines lockFile)

let refFile = ReferencesFile.FromLines(toLines refFileContent)

let packages =
[ for kv in refFile.Groups do
let packagesInGroup,_ = lockFile.GetOrderedPackageHull(kv.Key, refFile)
yield! packagesInGroup ]

let outPath = System.IO.Path.GetTempFileName()
Paket.RestoreProcess.createPaketPropsFile lockFile Seq.empty packages (FileInfo outPath)

let doc = XDocument.Load(outPath, LoadOptions.PreserveWhitespace)

let itemGroups = doc.Root.Elements (xname "ItemGroup") |> Seq.toList

match itemGroups with
| [groupMain] ->
groupMain
|> checkTargetFrameworkRestriction (lockFile.Groups.[Constants.MainDependencyGroup].Resolution.[Domain.PackageName "Newtonsoft.Json"].Settings.FrameworkRestrictions)
groupMain
|> checkContainsPackageRefs [ "Newtonsoft.Json","11.0.2" ]
| l ->
Assert.Fail(sprintf "expected one ItemGroup but was '%A'" l)

0 comments on commit 67b1422

Please sign in to comment.