-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Authentication via user token * Find repo based on username/repo_name * Create release with a given tag * Set the name on the release created
- Loading branch information
Showing
5 changed files
with
199 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
src/test/java/org/llorllale/mvn/plgn/releasecat/UploadTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* Copyright 2018 George Aristy | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.llorllale.mvn.plgn.releasecat; | ||
|
||
// @checkstyle AvoidStaticImport (3 lines) | ||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertThat; | ||
|
||
import com.jcabi.github.Release; | ||
import com.jcabi.github.Releases; | ||
import com.jcabi.github.Repo; | ||
import com.jcabi.github.Repos; | ||
import com.jcabi.github.mock.MkGithub; | ||
import java.io.IOException; | ||
import org.apache.maven.plugin.MojoFailureException; | ||
import org.junit.Test; | ||
|
||
/** | ||
* Tests for {@link Upload}. | ||
* | ||
* @author George Aristy (george.aristy@gmail.com) | ||
* @since 0.1.0 | ||
* @checkstyle MethodName (500 lines) | ||
*/ | ||
@SuppressWarnings("checkstyle:MultipleStringLiterals") | ||
public final class UploadTest { | ||
/** | ||
* Release should be created with the given tag. | ||
* | ||
* @throws Exception unexpected | ||
* @since 0.1.0 | ||
*/ | ||
@Test | ||
public void releaseIsCreated() throws Exception { | ||
final Repo repo = new MkGithub().repos() | ||
.create(new Repos.RepoCreate("my_user/my_project", false)); | ||
new Upload("Tag v1.0", "Name v1.0", () -> repo).execute(); | ||
assertNotNull( | ||
new Releases.Smart(repo.releases()).find("Tag v1.0") | ||
); | ||
} | ||
|
||
/** | ||
* Release should be created with the given name. | ||
* | ||
* @throws Exception unexpected | ||
* @since 0.1.0 | ||
*/ | ||
@Test | ||
public void releaseHasGivenName() throws Exception { | ||
final Repo repo = new MkGithub().repos() | ||
.create(new Repos.RepoCreate("my_user/my_project", false)); | ||
new Upload("Tag v1.0", "Name v1.0", () -> repo).execute(); | ||
assertThat( | ||
new Release.Smart(new Releases.Smart(repo.releases()).find("Tag v1.0")).name(), | ||
is("Name v1.0") | ||
); | ||
} | ||
|
||
/** | ||
* Mojo should wrap IOException in MojoFailureException. | ||
* | ||
* @throws Exception MojoFailureException | ||
* @since 0.1.0 | ||
*/ | ||
@Test(expected = MojoFailureException.class) | ||
public void mojoFailureIfIoError() throws Exception { | ||
new Upload( | ||
"my_user", "wrong_project", | ||
() -> { | ||
throw new IOException(); | ||
} | ||
).execute(); | ||
} | ||
|
||
/** | ||
* Mojo should fail if the configuration is not specified (ie. is null). This results in an | ||
* internal IllegalArgumentException. | ||
* | ||
* @throws Exception MojoFailureException | ||
* @since 0.1.0 | ||
*/ | ||
@Test(expected = MojoFailureException.class) | ||
public void mojoFailureIfConfigNotSpecified() throws Exception { | ||
new Upload().execute(); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/test/java/org/llorllale/mvn/plgn/releasecat/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright 2018 George Aristy | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** | ||
* Tests. | ||
* | ||
* @since 0.1.0 | ||
*/ | ||
package org.llorllale.mvn.plgn.releasecat; |
3520d14
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
1-fc28441b
discovered insrc/main/java/org/llorllale/mvn/plgn/releasecat/Upload.java
and submitted as #3. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.3520d14
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
1-fdf75b0d
discovered insrc/main/java/org/llorllale/mvn/plgn/releasecat/Upload.java
and submitted as #4. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.3520d14
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
1-3284a5e8
discovered insrc/main/java/org/llorllale/mvn/plgn/releasecat/Upload.java
and submitted as #5. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.