support version spec filter
authorEugene.Petrenko <eugene.petrenko@gmail.com>
Wed, 13 Jul 2011 19:55:01 +0000 (23:55 +0400)
committerEugene.Petrenko <eugene.petrenko@gmail.com>
Wed, 13 Jul 2011 19:55:01 +0000 (23:55 +0400)
nuget-extensions/nuget-commands/src/NuGetTeamCityListCommand.cs
nuget-extensions/nuget-tests/src/NuGetRunner_ListCommandTest.cs
nuget-extensions/nuget-tests/src/ProcessExecutor.cs

index 8282710894f464c101f181e214115d3c9cc96c3f..4b1260280d373740c3c1df203706e98b6ce921db 100644 (file)
@@ -6,8 +6,6 @@ using System.Linq.Expressions;
 using JetBrains.TeamCity.NuGet.ExtendedCommands.Util;\r
 using NuGet;\r
 using NuGet.Commands;\r
-using NuGet.Common;\r
-using PackageSourceProviderExtensions = NuGet.Common.PackageSourceProviderExtensions;\r
 \r
 namespace JetBrains.TeamCity.NuGet.ExtendedCommands\r
 {\r
@@ -37,8 +35,7 @@ namespace JetBrains.TeamCity.NuGet.ExtendedCommands
       System.Console.Out.WriteLine("Version: {0}", Version ?? "<null>");\r
       \r
       System.Console.Out.WriteLine("Checking for latest version...");\r
-      var packages = GetPackages();\r
-      foreach (var p in packages)\r
+      foreach (var p in GetPackages())\r
       {\r
         var msg = ServiceMessageFormatter.FormatMessage(\r
           "nuget-package",\r
@@ -59,8 +56,9 @@ namespace JetBrains.TeamCity.NuGet.ExtendedCommands
         .GetPackages()\r
         .Where(exp);\r
 \r
-      if (Version == null) return packages;\r
-      return packages.Where(VersionUtility.ParseVersionSpec(Version).ToDelegate());\r
+      if (string.IsNullOrWhiteSpace(Version)) return packages;\r
+      var versionSpec = VersionUtility.ParseVersionSpec(Version);\r
+      return packages.Where(versionSpec.ToDelegate());\r
     }\r
   }\r
 }\r
index 6e70e6ed5ba941c498c9feb3f91e010062539a00..96684b0c8e52b29051547d2c57c25158e078a64e 100644 (file)
@@ -15,5 +15,17 @@ namespace JetBrains.TeamCity.NuGet.Tests
         .AssertNoErrorOutput()\r
         .AssertOutputContains("##teamcity[nuget-package Id='NUnit' Version='2.5.10.11092']");\r
     }\r
+\r
+    [Test]\r
+    public void TestCommand_TeamListPublicVersion()\r
+    {\r
+      var r = ProcessExecutor.ExecuteProcess(NuGetRunner.Path.Value, NuGet.NuGetPath, "TeamCity.List", "-Id", "NUnit", "-Version", "(1.1.1, 2.5.8)", "-Source", NuGetConstants.DefaultFeedUrl)\r
+        .Dump()\r
+        .AssertExitedSuccessfully()\r
+        .AssertNoErrorOutput()\r
+        .AssertOutputContains("##teamcity[nuget-package Id='NUnit' Version='2.5.7.10213']");\r
+\r
+      Assert.IsFalse(r.Output.Contains("Version='2.5.10"));\r
+    }\r
   }\r
 }
\ No newline at end of file
index 56490556c8140fb3d81162774362f069e69a13be..d819d89eb762574c301c495b3e144c10452a41d7 100644 (file)
@@ -4,6 +4,7 @@ using System.IO;
 using System.Text;\r
 using System.Threading;\r
 using NUnit.Framework;\r
+using System.Linq;\r
 \r
 namespace JetBrains.TeamCity.NuGet.Tests\r
 {\r
@@ -14,7 +15,7 @@ namespace JetBrains.TeamCity.NuGet.Tests
       var pi = new ProcessStartInfo\r
                  {\r
                    FileName = exe,\r
-                   Arguments = string.Join(" ", args),\r
+                   Arguments = string.Join(" ", args.Select(x=>x.Contains(' ') ? "\"" + x + "\"" : x)),\r
                    RedirectStandardError = true,\r
                    RedirectStandardOutput = true,\r
                    RedirectStandardInput = true,\r