-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unit tests #133
Merged
Merged
Unit tests #133
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Contributing to this repo | ||
|
||
## Setup | ||
|
||
### Personal access token (PAT) | ||
|
||
Follow [these](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) instructions to configurate a personal access token. | ||
|
||
Only permissions needed: | ||
- public_repo | ||
|
||
Save the token to a secure location. Click the "Configure SSO" button and "Authorize" if applicable. | ||
|
||
### Config | ||
|
||
```shell | ||
cp config.example.json config.json | ||
|
||
# Add your GitHub username and token | ||
$EDITOR config.json | ||
|
||
# Export the JSON credentials into an environment variable | ||
export CONFIG=$(<config.json) | ||
``` | ||
|
||
## Virtual environment | ||
|
||
### Install dependencies | ||
Instructions for POSIX bash/zsh (see [here](https://docs.python.org/3/library/venv.html) for syntax for other shells): | ||
```shell | ||
python3 -m venv env | ||
source env/bin/activate | ||
python3 -m pip install --upgrade pip | ||
python3 -m pip install -r requirements.txt -r dev-requirements.txt | ||
source env/bin/activate | ||
``` | ||
|
||
## Testing locally | ||
|
||
```shell | ||
PYTHONPATH=hubcap python -m pytest | ||
``` | ||
|
||
## Run in test mode | ||
|
||
```shell | ||
export ENV=test | ||
./cron.sh | ||
``` | ||
|
||
### Optional configuration environment variables | ||
``` | ||
# Default value is the `git-tmp` directory within the current working directory | ||
# This directory will be deleted by default at the end of the run | ||
export GIT_TMP=git-tmp | ||
``` | ||
|
||
### Optional parameters | ||
Preserve commits/build artifacts within the `$GIT_TMP` directory | ||
``` | ||
export ENV=test | ||
./cron.sh --no-cleanup | ||
``` | ||
|
||
## Run in production mode | ||
|
||
**WARNING:** Use with caution -- _will_ modify state. | ||
```shell | ||
export ENV=prod | ||
./cron.sh | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
black==22.6.0 | ||
pytest |
Empty file.
File renamed without changes.
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
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 |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
|
||
import package | ||
|
||
from cmd import * | ||
from git_helper import * | ||
|
||
|
||
def parse_semver_tag(tag): | ||
|
Empty file.
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,111 @@ | ||
import pytest | ||
from hubcap.version import is_valid_semver_tag | ||
|
||
|
||
@pytest.fixture | ||
def semver_20_valid(): | ||
"""Valid SemVer 2.0 versions""" | ||
# Most test cases from https://regex101.com/r/Ly7O1x/3/ | ||
return [ | ||
# Begin test cases from https://regex101.com/r/Ly7O1x/3/ | ||
"0.0.4", | ||
"1.2.3", | ||
"10.20.30", | ||
"1.1.2-prerelease+meta", | ||
"1.1.2+meta", | ||
"1.1.2+meta-valid", | ||
"1.0.0-alpha", | ||
"1.0.0-beta", | ||
"1.0.0-alpha.beta", | ||
"1.0.0-alpha.beta.1", | ||
"1.0.0-alpha.1", | ||
"1.0.0-alpha0.valid", | ||
"1.0.0-alpha.0valid", | ||
"1.0.0-alpha-a.b-c-somethinglong+build.1-aef.1-its-okay", | ||
"1.0.0-rc.1+build.1", | ||
"2.0.0-rc.1+build.123", | ||
"1.2.3-beta", | ||
"10.2.3-DEV-SNAPSHOT", | ||
"1.2.3-SNAPSHOT-123", | ||
"1.0.0", | ||
"2.0.0", | ||
"1.1.7", | ||
"2.0.0+build.1848", | ||
"2.0.1-alpha.1227", | ||
"1.0.0-alpha+beta", | ||
"1.2.3----RC-SNAPSHOT.12.9.1--.12+788", | ||
"1.2.3----R-S.12.9.1--.12+meta", | ||
"1.2.3----RC-SNAPSHOT.12.9.1--.12", | ||
"1.0.0+0.build.1-rc.10000aaa-kk-0.1", | ||
"99999999999999999999999.999999999999999999.99999999999999999", | ||
"1.0.0-0A.is.legal", | ||
# Begin custom test cases | ||
"1.0.3-post1", | ||
"0.8.0-a1", | ||
"0.8.0-b2", | ||
"0.8.0-rc3", | ||
] | ||
|
||
|
||
@pytest.fixture | ||
def semver_20_invalid(): | ||
"""Invalid SemVer 2.0 versions""" | ||
# Most test cases from https://regex101.com/r/Ly7O1x/3/ | ||
return [ | ||
# Begin test cases from https://regex101.com/r/Ly7O1x/3/ | ||
"1", | ||
"1.2", | ||
"1.2.3-0123", | ||
"1.2.3-0123.0123", | ||
"1.1.2+.123", | ||
"+invalid", | ||
"-invalid", | ||
"-invalid+invalid", | ||
"-invalid.01", | ||
"alpha", | ||
"alpha.beta", | ||
"alpha.beta.1", | ||
"alpha.1", | ||
"alpha+beta", | ||
"alpha_beta", | ||
"alpha.", | ||
"alpha..", | ||
"beta", | ||
"1.0.0-alpha_beta", | ||
"-alpha.", | ||
"1.0.0-alpha..", | ||
"1.0.0-alpha..1", | ||
"1.0.0-alpha...1", | ||
"1.0.0-alpha....1", | ||
"1.0.0-alpha.....1", | ||
"1.0.0-alpha......1", | ||
"1.0.0-alpha.......1", | ||
"01.1.1", | ||
"1.01.1", | ||
"1.1.01", | ||
"1.2", | ||
"1.2.3.DEV", | ||
"1.2-SNAPSHOT", | ||
"1.2.31.2.3----RC-SNAPSHOT.12.09.1--..12+788", | ||
"1.2-RC-SNAPSHOT", | ||
"-1.0.3-gamma+b7718", | ||
"+justmeta", | ||
"9.8.7+meta+meta", | ||
"9.8.7-whatever+meta+meta", | ||
"99999999999999999999999.999999999999999999.99999999999999999----RC-SNAPSHOT.12.09.1--------------------------------..12", | ||
# Begin custom test cases | ||
"1.0.3.post1", | ||
"0.8.0a1", | ||
"0.8.0b2", | ||
"0.8.0rc3", | ||
Comment on lines
+98
to
+100
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 #130 will move these up to the "supported" category |
||
] | ||
|
||
|
||
def test_regex_valid(semver_20_valid): | ||
for version in semver_20_valid: | ||
assert is_valid_semver_tag(version) | ||
|
||
|
||
def test_regex_invalid(semver_20_invalid): | ||
for version in semver_20_invalid: | ||
assert not is_valid_semver_tag(version) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I'm unfamiliar with this syntax, so just checking that the lonely
<
is meant to be there?