Skip to content
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

BATS tests Dockerfile #44

Merged
merged 3 commits into from Aug 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
@@ -0,0 +1,2 @@
build
dist
33 changes: 33 additions & 0 deletions Dockerfile-bats
@@ -0,0 +1,33 @@
FROM python:2

ARG SPEC=https://developers.linode.com/openapi.yaml
ARG TOKEN

RUN apt-get update && apt-get install -y python3 python3-pip bats
RUN pip install requests terminaltables colorclass PyYAML enum34
RUN pip3 install requests terminaltables colorclass PyYAML enum34

ENV PYTHONPATH=.
ENV PATH="/usr/local/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/.local/bin"

WORKDIR /src/linode-cli

COPY . .

# Build and Install Linode CLI
RUN git submodule init \
&& git submodule update \
&& make build SPEC=${SPEC} \
&& make install SPEC=${SPEC} \
&& cd dist \
&& pip install --user $(ls) \
&& echo -n "[DEFAULT]\ntoken = ${TOKEN}" > /root/.linode-cli
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This config file will work, but a real config file would have keys for image, type, and region


WORKDIR /src

# Install BATS testing framework
RUN git clone https://github.com/bats-core/bats-core.git \
&& cd bats-core \
&& ./install.sh /usr/local

CMD bats /src/linode-cli/test/linodes /src/linode-cli/test/domains
9 changes: 9 additions & 0 deletions README.rst
Expand Up @@ -233,6 +233,15 @@ Running the tests is simple. The only requirement is that you have a .linode-cli

./test/test-runner.sh

**Running Tests via Docker**

Run the following command to build the tests container:

docker build -f Dockerfile-bats -t linode-cli-tests --build-arg TOKEN=$INSERT_YOUR_TOKEN_HERE .

Run the following command to run the test

docker run --rm linode-cli-tests

Contributing
------------
Expand Down