-
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.
- Loading branch information
Showing
5 changed files
with
82 additions
and
0 deletions.
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,24 @@ | ||
sudo: required | ||
|
||
language: python | ||
python: | ||
- "3.6" | ||
|
||
env: | ||
- CONTAINER_IMAGE_NAME=quay.io/cosee-concourse/naming-resource TAG=latest | ||
|
||
services: | ||
- docker | ||
|
||
install: | ||
- pip install -r opt/requirements.txt | ||
|
||
script: | ||
- pytest | ||
- ./build.sh | ||
|
||
after_success: | ||
- if [ "$TRAVIS_BRANCH" == "master" ]; then | ||
docker login -u="$QUAY_USER" -p="$QUAY_APIKEY" quay.io; | ||
docker push $CONTAINER_IMAGE_NAME; | ||
fi |
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 @@ | ||
docker build --pull -t $CONTAINER_IMAGE_NAME:$TAG . |
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,8 @@ | ||
import os | ||
|
||
def write_to_file(filepath, name): | ||
with open(filepath, "w+") as file: | ||
file.write(name) | ||
|
||
def read(filepath, filename): | ||
return open(os.path.join(filepath, filename)).read() |
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,28 @@ | ||
import unittest | ||
import input | ||
from unittest.mock import patch | ||
from concourse_common import test_common | ||
import json | ||
|
||
class TestInput(unittest.TestCase): | ||
|
||
@patch("input.file_io") | ||
def test_call_to_fileIO(self, mock_io): | ||
test = "test/test" | ||
test_common.put_stdin(json.dumps({"source": {"prefix": "test"}, "version": {"version": "1.1.0"}})) | ||
input.execute(test) | ||
mock_io.write_to_file.assert_any_call(test + "/default", "test_1_1_0") | ||
mock_io.write_to_file.assert_any_call(test + "/heroku", "test-1-1-0") | ||
|
||
def test_invalid_prefix(self): | ||
test = "test/test" | ||
test_common.put_stdin(json.dumps({"source": {"prefix": "tes2234"}, "version": {"version": "1.1.0"}})) | ||
self.assertEquals(input.execute(test), -1) | ||
|
||
@patch("input.file_io") | ||
@patch("input.json") | ||
def test_call_to_json(self, mock_io, mock_io2): | ||
test = "test/test" | ||
test_common.put_stdin(json.dumps({"source": {"prefix": "test"}, "version": {"version": "1.1.0"}})) | ||
input.execute(test) | ||
mock_io.dumps.assert_any_call({"version": {"version": "1.1.0"}}) |
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,21 @@ | ||
import name_generator | ||
import unittest | ||
|
||
class TestOutput(unittest.TestCase): | ||
|
||
|
||
def test_output_default(self): | ||
out = name_generator.generate_default("test", "1.1.2") | ||
self.assertEquals=(out, "test-1-1-2") | ||
|
||
def test_output_heroku(self): | ||
out = name_generator.generate_default("test", "1.1.2") | ||
self.assertEquals=(out, "test_1_1_2") | ||
|
||
def test_output_default_emptyversion(self): | ||
out = name_generator.generate_default("test", "") | ||
self.assertEquals=(out, "test-") | ||
|
||
def test_output_heroku_emptyversion(self): | ||
out = name_generator.generate_default("test", "") | ||
self.assertEquals=(out, "test_") |