PageRenderTime 26ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/src/test/Fake.Core.UnitTests/Fake.DotNet.NuGet.fs

https://github.com/fsharp/FAKE
F# | 122 lines | 101 code | 21 blank | 0 comment | 5 complexity | 75d57b9d99ecd378816858d4e390f6a9 MD5 | raw file
Possible License(s): Apache-2.0
  1. module Fake.DotNet.NuGetTests
  2. open Fake.Core
  3. open Fake.DotNet.NuGet
  4. open Fake.DotNet.NuGet.Version
  5. open Expecto
  6. [<Tests>]
  7. let tests =
  8. testList "Fake.DotNet.NuGet.Tests" [
  9. testCase "Test that the default nuget push arguments returns empty string" <| fun _ ->
  10. let cli =
  11. NuGet.NuGetPushParams.Create()
  12. |> NuGet.toPushCliArgs
  13. |> Args.toWindowsCommandLine
  14. Expect.isEmpty cli "Empty push args."
  15. testCase "Test that the nuget push arguments with all params set returns correct string" <| fun _ ->
  16. let param =
  17. { NuGet.NuGetPushParams.Create() with
  18. DisableBuffering = true
  19. ApiKey = Some "abc123"
  20. NoSymbols = true
  21. NoServiceEndpoint = true
  22. Source = Some "MyNuGetSource"
  23. SymbolApiKey = Some "MySymbolApiKey"
  24. SymbolSource = Some "MySymbolSource"
  25. Timeout = Some <| System.TimeSpan.FromMinutes 6.00001
  26. PushTrials = 5 }
  27. let cli =
  28. param
  29. |> NuGet.toPushCliArgs
  30. |> Args.toWindowsCommandLine
  31. let expected = "-ApiKey abc123 -DisableBuffering -NoSymbols -NoServiceEndpoint -Source MyNuGetSource -SymbolApiKey MySymbolApiKey -SymbolSource MySymbolSource -Timeout 360"
  32. Expect.equal cli expected "Push args generated correctly."
  33. test "Incrementing Patch for a SemVerInfo" {
  34. Expect.equal (SemVer.parse("1.1.0") |> IncPatch |> string) "1.1.1" "Incremented Patch from 1.1.0 should be 1.1.1"
  35. }
  36. test "Incrementing Minor for a SemVerInfo" {
  37. Expect.equal (SemVer.parse("1.1.1") |> IncMinor |> string) "1.2.0" "Incremented Minor from 1.1.1 should be 1.2.0"
  38. }
  39. test "Incrementing Major for a SemVerInfo" {
  40. Expect.equal (SemVer.parse("1.1.1") |> IncMajor |> string) "2.0.0" "Incremented Patch from 1.1.1 should be 2.0.0"
  41. }
  42. test "Getting the NuGet feed URL return V3" {
  43. Expect.equal NuGet.galleryV3 "https://api.nuget.org/v3/index.json" "NuGet feed V3 API is used"
  44. }
  45. test "Getting NuGet resource service URL" {
  46. Expect.isNotEmpty (NuGet.getRepoUrl()) "Get Repo URL will return NuGet service URL"
  47. }
  48. testCase "Getting latest version of FAKE from NuGet feed" <| fun _ ->
  49. let package: NuGet.NugetPackageInfo = NuGet.getLatestPackage (NuGet.getRepoUrl()) "FAKE"
  50. Expect.isTrue package.IsLatestVersion "getting latest version of a package"
  51. testCase "Getting latest version of FAKE and package info are populated" <| fun _ ->
  52. let package: NuGet.NugetPackageInfo = NuGet.getLatestPackage (NuGet.getRepoUrl()) "FAKE"
  53. Expect.equal package.Id "FAKE" "Id filled"
  54. Expect.isNotEmpty package.Version "Version filled"
  55. Expect.isNotEmpty package.Description "Description filled"
  56. Expect.isNotEmpty package.Summary "Id filled"
  57. Expect.isTrue package.IsLatestVersion "IsLatestVersion filled"
  58. Expect.isNotEmpty package.Authors "Authors filled"
  59. Expect.isNotEmpty package.Owners "Owners filled"
  60. Expect.isNotEmpty package.Tags "Tags filled"
  61. Expect.isNotEmpty package.ProjectUrl "ProjectUrl filled"
  62. Expect.isNotEmpty package.LicenseUrl "LicenseUrl filled"
  63. Expect.equal package.Title "FAKE" "Title filled"
  64. testCase "Requesting specific version of FAKE" <| fun _ ->
  65. let package: NuGet.NugetPackageInfo = NuGet.getPackage (NuGet.getRepoUrl()) "FAKE" "1.46.2"
  66. Expect.isFalse package.IsLatestVersion "getting version 1.46.2 of FAKE"
  67. testCase "Requesting un-registered version of FAKE throws exception" <| fun _ ->
  68. Expect.throws (fun _ -> NuGet.getPackage (NuGet.getRepoUrl()) "FAKE" "-1.55.0" |> ignore) "Version -1.55.0 is not registered for FAKE!"
  69. testCase "Requesting specific version of FAKE and package info are populated" <| fun _ ->
  70. let package: NuGet.NugetPackageInfo = NuGet.getPackage (NuGet.getRepoUrl()) "FAKE" "1.46.2"
  71. Expect.equal package.Id "FAKE" "Id filled"
  72. Expect.equal package.Version "1.46.2" "Version filled"
  73. Expect.isNotEmpty package.Description "Description filled"
  74. Expect.isNotEmpty package.Summary "Id filled"
  75. Expect.isFalse package.IsLatestVersion "IsLatestVersion filled"
  76. Expect.isNotEmpty package.Authors "Authors filled"
  77. Expect.isNotEmpty package.Owners "Owners filled"
  78. Expect.isNotEmpty package.Tags "Tags filled"
  79. Expect.isNotEmpty package.ProjectUrl "ProjectUrl filled"
  80. Expect.isNotEmpty package.LicenseUrl "LicenseUrl filled"
  81. Expect.equal package.Title "FAKE" "Title filled"
  82. testCase "Search by title returns results for matching packages by provided title" <| fun _ ->
  83. let package =
  84. NuGet.searchByTitle
  85. (NuGet.getRepoUrl())
  86. "FAKE"
  87. |> List.tryFind (fun p -> p.Id = "FAKE")
  88. Expect.isSome package "FAKE package was not found in NuGet"
  89. let p = package.Value
  90. Expect.equal p.Id "FAKE" "Id filled"
  91. Expect.isNotEmpty p.Version "Version filled"
  92. Expect.isNotEmpty p.Description "Description filled"
  93. Expect.isNotEmpty p.Summary "Summary filled"
  94. Expect.isFalse p.IsLatestVersion "IsLatestVersion filled"
  95. Expect.isNotEmpty p.Authors "Authors filled"
  96. Expect.isNotEmpty p.Owners "Owners filled"
  97. Expect.isNotEmpty p.Tags "Tags filled"
  98. Expect.isNotEmpty p.ProjectUrl "ProjectUrl filled"
  99. Expect.isNotEmpty p.LicenseUrl "LicenseUrl filled"
  100. Expect.equal p.Title "FAKE" "Title filled"
  101. ]