Skip to content

Commit

Permalink
renamed .travis.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
fweirich committed Feb 21, 2017
1 parent 054ccd4 commit c518032
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .travis.yml
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
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker build --pull -t $CONTAINER_IMAGE_NAME:$TAG .
8 changes: 8 additions & 0 deletions opt/resource/file_io.py
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()
28 changes: 28 additions & 0 deletions opt/tests/test_input.py
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"}})
21 changes: 21 additions & 0 deletions opt/tests/test_name_generator.py
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_")

0 comments on commit c518032

Please sign in to comment.