l0rd / cUnit

xUnit for your Dockerfiles
Apache License 2.0
34 stars 1 forks source link

Implement IS_INSTALLED, OS_MATCH, FILE_CONTAINS #3

Open xinity opened 8 years ago

xinity commented 8 years ago

hi,

been trying to use test templates like this:

@BEFORE RUN DPKG
ASSERT_TRUE IS_INSTALLED 'supervisor'
ASSERT_TRUE IS_INSTALLED 'postfix'

@BEFORE RUN CP
ASSERT_TRUE FILE_EXISTS '/etc/skel/.bashrc'
ASSERT_TRUE FILE_CONTAINS 'LOGNAME'
ASSERT_TRUE FILE_EXISTS '/etc/skel/.vimrc'
ASSERT_TRUE FILE_CONTAINS 'autocmd'

@BEFORE CMD
ASSERT_TRUE FILE_EXISTS '/etc/supervisor/conf.d/postfix.conf'

but here is the output of docker-unit:

/tmp/docker-unit/bundles/linux/amd64/docker-unit .
Found test file: Dockerfile_test!

FATA[0000] Condition IS_INSTALLED is not supported. Only USER_EXISTS and FILE_EXISTS are currently supported. Please open an issue if you want to add support for it.

did i missed something ?

also tried OS_MATCH which failed as well

l0rd commented 8 years ago

IS_INSTALLED and OS_MATCH are not supported :disappointed:

Only USER_EXISTS and FILE_EXISTS are currently supported. Please open an issue if you want to add support for it.

But since you have request it I will implement IS_INSTALLED, OS_MATCH, FILE_CONTAINS really soon.

xinity commented 8 years ago

Awesome !

can i be of any help ? is it hard to implement ALL test templates ?

let me know, i'll be glad to give a hand

Le mer. 30 déc. 2015 à 09:47, Mario Loriedo notifications@github.com a écrit :

IS_INSTALLED and OS_MATCH are not supported [image: :disappointed:]

Only USER_EXISTS and FILE_EXISTS are currently supported. Please open an issue if you want to add support for it.

But since you have request it I will implement IS_INSTALLED, OS_MATCH, FILE_CONTAINS really soon.

— Reply to this email directly or view it on GitHub https://github.com/l0rd/docker-unit/issues/3#issuecomment-167958913.

l0rd commented 8 years ago

I'll create a new issue for you next week. We would like to use regular expressions to match dockerfiles instructions with @BEFORE and @AFTER. I'll describe it better in the issue.

In the meantime you could try to build docker-unit and run go test locally and provide some feedback about that ?

xinity commented 8 years ago

FILE_CONTAINS is implemented in PR: https://github.com/l0rd/docker-unit/pull/7

waiting to be validated and merged :)

l0rd commented 8 years ago

I'm back from a few days off. Expect to be it merged this afternoon.

On Monday, 4 January 2016, Rachid Zarouali notifications@github.com wrote:

FILE_CONTAINS is implemented in PR: #7 https://github.com/l0rd/docker-unit/pull/7

waiting to be validated and merged :)

— Reply to this email directly or view it on GitHub https://github.com/l0rd/docker-unit/issues/3#issuecomment-168726931.

xinity commented 8 years ago

nice ! thanks !

if you have some spare time (which i doubt while being back from a few days off) can you take a look at my latest issue regarding IS_RUNNING and IS_LISTENING_ON_PORT.

if we can manage to implement them, we'll have something really powerfull to make unit tests :)

let me know :)

l0rd commented 8 years ago

I've reviewed PR #7. Great job ! I've added some comments. The most important one is about rebasing your branch, the rest are minor changes.

I'll have a look at #8 later :smiley: