Skip to content

Commit

Permalink
#690: Adding a unit test testing the issue
Browse files Browse the repository at this point in the history
  • Loading branch information
andrzejj0 authored and slachiewicz committed Sep 18, 2022
1 parent 9d9991e commit fc5f092
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -325,4 +325,25 @@ private void testSkipResolution( String version )
assertThat( changeRecorder.getChanges(), hasItem( new VersionChange( "default-group",
"parent-artifact", "1.0.0", version ) ) );
}

@Test
public void testShouldUpgradeToSnapshot() throws MojoExecutionException, XMLStreamException, MojoFailureException
{
mojo.getProject().setParent( new MavenProject()
{{
setGroupId( "default-group" );
setArtifactId( "parent-artifact" );
setVersion( "0.9.0" );
}} );
mojo.allowSnapshots = true;
mojo.parentVersion = "[0,1.0.1-SNAPSHOT]";
try ( MockedStatic<PomHelper> pomHelper = mockStatic( PomHelper.class ) )
{
pomHelper.when( () -> PomHelper.setProjectParentVersion( any(), any() ) ).thenReturn( true );
mojo.update( null );
}
assertThat( changeRecorder.getChanges(),
hasItem( new VersionChange( "default-group", "parent-artifact", "0.9.0",
"1.0.1-SNAPSHOT" ) ) );
}
}

0 comments on commit fc5f092

Please sign in to comment.