Tests are running in dev env

This commit is contained in:
Jon Herron 2023-04-12 13:15:05 -04:00
parent 625d1e0402
commit a6e2f4f382
7 changed files with 40 additions and 8 deletions

View File

@ -1,7 +0,0 @@
FROM python:alpine AS base
RUN \
--mount=type=cache,target=/var/cache/apk \
apk add -U make
WORKDIR /app

View File

@ -1,7 +1,19 @@
SRC := spiff_element_units
TESTS := tests
DEV_SERVICE := dev
MY_USER := $(shell id -u)
MY_GROUP := $(shell id -g)
ME := $(MY_USER):$(MY_GROUP)
AS_ME := docker compose run -u $(ME) $(DEV_SERVICE)
.PHONY: all
all: dev-env
dev-env:
docker compose build --progress=plain $(DEV_SERVICE)
.PHONY: tests
tests:
$(AS_ME) unittest-parallel -vs $(TESTS) -p test_*.py -t .

13
dev/Dockerfile Normal file
View File

@ -0,0 +1,13 @@
FROM python:alpine AS base
RUN \
--mount=type=cache,target=/var/cache/apk \
apk add -U make
RUN python -m pip install --upgrade pip
WORKDIR /app
COPY dev/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

1
dev/requirements.txt Normal file
View File

@ -0,0 +1 @@
unittest-parallel == 1.5.3

View File

@ -2,4 +2,8 @@ services:
dev:
container_name: spiff-element-units-dev
build:
dockerfile: Dockerfile
context: .
dockerfile: dev/Dockerfile
volumes:
- ./spiff_element_units:/app/spiff_element_units
- ./tests:/app/tests

View File

@ -0,0 +1,2 @@
def this_returns_true():
return True

7
tests/test_sanity.py Normal file
View File

@ -0,0 +1,7 @@
from unittest import TestCase
from spiff_element_units import this_returns_true
class SanityTest(TestCase):
def test_it_returns_true(self):
assert this_returns_true()