more tests on push command
authorEugene Petrenko <eugene.petrenko@gmail.com>
Thu, 21 Jul 2011 16:21:34 +0000 (20:21 +0400)
committerEugene Petrenko <eugene.petrenko@gmail.com>
Thu, 21 Jul 2011 16:21:34 +0000 (20:21 +0400)
nuget-agent/src/jetbrains/buildServer/nuget/agent/commands/impl/CommandFactoryImpl.java
nuget-tests/src/jetbrains/buildServer/nuget/tests/agent/NuGetPushActoinFactoryTest.java

index ce2d78411847322237e8d20849275f0868f8e1e2..af7920eefb71765a30fc29c0c0f987d1b47f549d 100644 (file)
@@ -72,11 +72,17 @@ public class CommandFactoryImpl implements CommandFactory {
   public <T> T createPush(@NotNull final NuGetPublishParameters params,\r
                           @NotNull final File packagePath,\r
                           @NotNull final Callback<T> factory) throws RunBuildException {\r
-    return executeNuGet(params, Arrays.asList(params.getPublishSource()),\r
-            Arrays.asList(\r
-                    packagePath.getPath(),\r
-                    params.getApiKey()\r
-            ),\r
+    final List<String> arguments = new ArrayList<String>();\r
+    arguments.add(packagePath.getPath());\r
+    arguments.add(params.getApiKey());\r
+    if (params.getCreateOnly()) {\r
+      arguments.add("-CreateOnly");\r
+    }\r
+\r
+    return executeNuGet(\r
+            params,\r
+            Arrays.asList(params.getPublishSource()),\r
+            arguments,\r
             packagePath.getParentFile(),\r
             factory);\r
   }\r
index 782939ba6356a38bd43bf896d9df04bde34582c5..7890935fbeda396d54053a1632cd0a5480d07077 100644 (file)
@@ -66,6 +66,7 @@ public class NuGetPushActoinFactoryTest extends BaseTestCase {
       allowing(ps).getNuGetExeFile(); will(returnValue(myNuGet));\r
       allowing(ps).getApiKey(); will(returnValue("api-key-guid"));\r
       allowing(ps).getPublishSource(); will(returnValue("push-feed"));\r
+      allowing(ps).getCreateOnly(); will(returnValue(false));\r
 \r
       oneOf(myProcessFactory).executeCommandLine(ctx, myNuGet, Arrays.asList(myFile.getPath(), "api-key-guid", "-Source", "push-feed"), myFile.getParentFile());\r
     }});\r
@@ -73,4 +74,18 @@ public class NuGetPushActoinFactoryTest extends BaseTestCase {
     i.createPush(ctx, ps, myFile);\r
   }\r
 \r
+  @Test\r
+  public void test_command_push_no_pacakge() throws RunBuildException {\r
+    m.checking(new Expectations(){{\r
+      allowing(ps).getNuGetExeFile(); will(returnValue(myNuGet));\r
+      allowing(ps).getApiKey(); will(returnValue("api-key-guid"));\r
+      allowing(ps).getPublishSource(); will(returnValue("push-feed"));\r
+      allowing(ps).getCreateOnly(); will(returnValue(true));\r
+\r
+      oneOf(myProcessFactory).executeCommandLine(ctx, myNuGet, Arrays.asList(myFile.getPath(), "api-key-guid", "-CreateOnly", "-Source", "push-feed"), myFile.getParentFile());\r
+    }});\r
+\r
+    i.createPush(ctx, ps, myFile);\r
+  }\r
+\r
 }\r