integration test of NuGet against nuget trunk builds
authorEugene Petrenko <eugene.petrenko@gmail.com>
Fri, 15 Jul 2011 16:19:47 +0000 (20:19 +0400)
committerEugene Petrenko <eugene.petrenko@gmail.com>
Fri, 15 Jul 2011 16:19:47 +0000 (20:19 +0400)
nuget-extensions/nuget-tests/nuget-tests.csproj
nuget-extensions/nuget-tests/src/NuGetRunnerWithTrunk.cs [new file with mode: 0644]
nuget-extensions/nuget-tests/src/TempFilesHolder.cs

index 770e2c10fc8a96ea9457195db399882e6fb76627..597a2728f6afe41e183ee652e11d2572c2bf8c69 100644 (file)
@@ -51,6 +51,7 @@
     <Compile Include="src\NuGetConstants.cs" />\r
     <Compile Include="src\NuGetRunnerTest.cs" />\r
     <Compile Include="Properties\AssemblyInfo.cs" />\r
+    <Compile Include="src\NuGetRunnerWithTrunk.cs" />\r
     <Compile Include="src\NuGetRunner_ListCommandTest.cs" />\r
     <Compile Include="src\NuGetRunner_ListPackagesCommandTest.cs" />\r
     <Compile Include="src\PathSearcher.cs" />\r
diff --git a/nuget-extensions/nuget-tests/src/NuGetRunnerWithTrunk.cs b/nuget-extensions/nuget-tests/src/NuGetRunnerWithTrunk.cs
new file mode 100644 (file)
index 0000000..674b65d
--- /dev/null
@@ -0,0 +1,82 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.IO;\r
+using System.Net;\r
+using NUnit.Framework;\r
+\r
+namespace JetBrains.TeamCity.NuGet.Tests\r
+{\r
+  [TestFixture("bt4")]\r
+  [TestFixture("bt22")]\r
+  [TestFixture("bt21")]  \r
+  public class NuGetRunnerWithTrunk\r
+  {\r
+    private readonly Lazy<string> home;\r
+    \r
+    private readonly Lazy<string> nuget;\r
+\r
+    public NuGetRunnerWithTrunk(string bt)\r
+    {\r
+\r
+      home = new Lazy<string>(() =>\r
+                                {\r
+                                  var homePath = Path.GetTempFileName();\r
+                                  File.Delete(homePath);\r
+                                  Directory.CreateDirectory(homePath);\r
+                                  return homePath;\r
+                                });\r
+      \r
+      nuget = new Lazy<string>(() =>\r
+                                 {\r
+                                   string url = "http://ci.nuget.org:8080/guestAuth/repository/download/" + bt +\r
+                                                "/.lastSuccessful/Console/NuGet.exe";\r
+                                   var nugetPath = Path.Combine(home.Value, "NuGet.exe");\r
+                                   var cli = new WebClient();\r
+                                   cli.DownloadFile(url, nugetPath);\r
+                                   return nugetPath;\r
+                                 });\r
+      \r
+     \r
+    }\r
+\r
+    [TestFixtureTearDown]\r
+    public void Cleanup()\r
+    {\r
+      if (home.IsValueCreated)\r
+      {\r
+        Directory.Delete(home.Value, true);\r
+      }\r
+    }\r
+\r
+    [Test]\r
+    public void Test_Ping()\r
+    {\r
+      DoTest("TeamCity.Ping");\r
+    }\r
+\r
+    [Test]\r
+    public void Test_List_NUnit_Remote()\r
+    {\r
+      DoTest("TeamCity.List", "-Id", "NUnit")\r
+        .AssertOutputContains("##teamcity[nuget-package Id='NUnit' Version='2.5.10.11092']");\r
+    }\r
+\r
+    [Test]\r
+    public void Test_List_NUnit_Local()\r
+    {\r
+      DoTest("TeamCity.List", "-Id", "Web", "-Source", Files.LocalFeed)\r
+        .AssertOutputContains("##teamcity[nuget-package Id='Web' Version='1.1.1']");\r
+    }\r
+    \r
+    private ProcessExecutor.Result DoTest(params string[] argz)\r
+    {\r
+      var az = new List<string>();\r
+      az.Add(nuget.Value);\r
+      az.AddRange(argz);\r
+\r
+      return ProcessExecutor.ExecuteProcess(Files.NuGetRunnerExe, az.ToArray())\r
+        .Dump()\r
+        .AssertExitedSuccessfully();\r
+    }\r
+  }\r
+}
\ No newline at end of file
index b560c8aa35a95616e55efb7b0de84faa62149768..c71790d959aafd19548665334faabd2dd00cc5c9 100644 (file)
@@ -17,19 +17,28 @@ namespace JetBrains.TeamCity.NuGet.Tests
       }\r
     }\r
 \r
-    public static void WithTempDirectory(Action<string> action)\r
+    public static T WithTempDirectory<T>(Func<string, T> action)\r
     {\r
       string tmp = Path.GetTempFileName();\r
       File.Delete(tmp);\r
       Directory.CreateDirectory(tmp);\r
       try\r
       {\r
-        action(tmp);\r
+        return action(tmp);\r
       }\r
       finally\r
       {\r
-        Directory.Delete(tmp,true);\r
+        Directory.Delete(tmp, true);\r
       }\r
     }\r
+\r
+    public static void WithTempDirectory(Action<string> action)\r
+    {\r
+      WithTempDirectory(t =>\r
+                          {\r
+                            action(t);\r
+                            return t;\r
+                          });\r
+    }\r
   }\r
 }
\ No newline at end of file