Mercurial > hg > mercurial
comparison mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutTest.java @ 935:eb3e0285ae52
TW-43138 Migrate to fresh auto checkout api
author | Dmitry.Treskunov@UNIT-412.Labs.IntelliJ.Net |
---|---|
date | Wed, 11 Nov 2015 21:03:31 +0300 |
parents | 3db6c332fc3b |
children | 68160fb667b1 |
comparison
equal
deleted
inserted
replaced
934:3db6c332fc3b | 935:eb3e0285ae52 |
---|---|
27 import jetbrains.buildServer.buildTriggers.vcs.mercurial.ext.MercurialExtensionManager; | 27 import jetbrains.buildServer.buildTriggers.vcs.mercurial.ext.MercurialExtensionManager; |
28 import jetbrains.buildServer.util.FileUtil; | 28 import jetbrains.buildServer.util.FileUtil; |
29 import jetbrains.buildServer.util.TestFor; | 29 import jetbrains.buildServer.util.TestFor; |
30 import jetbrains.buildServer.vcs.*; | 30 import jetbrains.buildServer.vcs.*; |
31 import jetbrains.buildServer.vcs.impl.VcsRootImpl; | 31 import jetbrains.buildServer.vcs.impl.VcsRootImpl; |
32 import org.hamcrest.CoreMatchers; | |
32 import org.jetbrains.annotations.NotNull; | 33 import org.jetbrains.annotations.NotNull; |
33 import org.jmock.Expectations; | 34 import org.jmock.Expectations; |
34 import org.jmock.Mockery; | 35 import org.jmock.Mockery; |
35 import org.testng.annotations.BeforeMethod; | 36 import org.testng.annotations.BeforeMethod; |
36 import org.testng.annotations.Test; | 37 import org.testng.annotations.Test; |
104 } | 105 } |
105 | 106 |
106 public void auto_checkout_when_hg_client_not_found() throws Exception { | 107 public void auto_checkout_when_hg_client_not_found() throws Exception { |
107 VcsRootImpl root = new VcsRootBuilder().withUrl(copyRepository(myTempFiles, simpleRepo()).getAbsolutePath()).withHgPath("invalid_hg_path").build(); | 108 VcsRootImpl root = new VcsRootBuilder().withUrl(copyRepository(myTempFiles, simpleRepo()).getAbsolutePath()).withHgPath("invalid_hg_path").build(); |
108 | 109 |
109 AgentCheckoutAbility agentCheckoutAbility = myVcsSupport.canCheckout(new VcsRootEntry(root, CheckoutRules.DEFAULT), myContext.mock(AgentRunningBuild.class, "build" + myBuildCounter++)); | 110 AgentCheckoutAbility agentCheckoutAbility = myVcsSupport.canCheckout(root, CheckoutRules.DEFAULT, myContext.mock(AgentRunningBuild.class, "build" + myBuildCounter++)); |
110 | 111 |
111 assertThat(agentCheckoutAbility.getCanNotCheckoutReason(), containsString(AgentCheckoutAbility.NO_VCS_CLIENT)); | 112 assertThat(agentCheckoutAbility.getCanNotCheckoutReason().getType(), CoreMatchers.equalTo(AgentCheckoutAbility.NO_VCS_CLIENT)); |
112 } | 113 } |
113 | 114 |
114 public void auto_checkout_when_unsupported_include_rule_is_used() throws Exception { | 115 public void auto_checkout_when_unsupported_include_rule_is_used() throws Exception { |
115 VcsRootImpl root = createVcsRoot(simpleRepo()); | 116 VcsRootImpl root = createVcsRoot(simpleRepo()); |
116 | 117 |
117 AgentCheckoutAbility agentCheckoutAbility = myVcsSupport.canCheckout(new VcsRootEntry(root, new CheckoutRules("+:subdir=>subdir2")), myContext.mock(AgentRunningBuild.class, "build" + myBuildCounter++)); | 118 AgentCheckoutAbility agentCheckoutAbility = myVcsSupport.canCheckout(root, new CheckoutRules("+:subdir=>subdir2"), myContext.mock(AgentRunningBuild.class, "build" + myBuildCounter++)); |
118 | 119 |
119 assertThat(agentCheckoutAbility.getCanNotCheckoutReason(), containsString("Invalid include rule: subdir=>subdir2")); | 120 assertThat(agentCheckoutAbility.getCanNotCheckoutReason().describe(true), containsString("Invalid include rule: subdir=>subdir2")); |
120 } | 121 } |
121 | 122 |
122 public void checkout_on_agent() throws IOException, VcsException { | 123 public void checkout_on_agent() throws IOException, VcsException { |
123 testUpdate(createVcsRoot(simpleRepo()), "4:b06a290a363b", "cleanPatch1/after", new IncludeRule(".", ".", null)); | 124 testUpdate(createVcsRoot(simpleRepo()), "4:b06a290a363b", "cleanPatch1/after", new IncludeRule(".", ".", null)); |
124 } | 125 } |
167 final AgentRunningBuild build = myContext.mock(AgentRunningBuild.class, "build" + myBuildCounter++); | 168 final AgentRunningBuild build = myContext.mock(AgentRunningBuild.class, "build" + myBuildCounter++); |
168 myContext.checking(new Expectations() {{ | 169 myContext.checking(new Expectations() {{ |
169 allowing(build).getBuildLogger(); will(returnValue(myLogger)); | 170 allowing(build).getBuildLogger(); will(returnValue(myLogger)); |
170 allowing(build).getSharedConfigParameters(); will(returnValue(sharedConfigParameters)); | 171 allowing(build).getSharedConfigParameters(); will(returnValue(sharedConfigParameters)); |
171 }}); | 172 }}); |
172 assertNull(myVcsSupport.canCheckout(new VcsRootEntry(vcsRoot, new CheckoutRules("")), build).getCanNotCheckoutReason()); | 173 assertNull(myVcsSupport.canCheckout(vcsRoot, new CheckoutRules(""), build).getCanNotCheckoutReason()); |
173 myVcsSupport.getUpdater(vcsRoot, new CheckoutRules(""), version, myWorkDir, build, false).process(includeRule, actualWorkDir); | 174 myVcsSupport.getUpdater(vcsRoot, new CheckoutRules(""), version, myWorkDir, build, false).process(includeRule, actualWorkDir); |
174 | 175 |
175 File hgDir = new File(actualWorkDir, ".hg"); | 176 File hgDir = new File(actualWorkDir, ".hg"); |
176 assertTrue(hgDir.isDirectory()); | 177 assertTrue(hgDir.isDirectory()); |
177 return actualWorkDir; | 178 return actualWorkDir; |