sstephenson/bats

Dynamic test creation

Opened this issue · 1 comments

It would be nice if I could do something like this:

declare -a packages
packages+=(cloud-utils)
packages+=(curl)
packages+=(dstat)
packages+=(git-core)
packages+=(htop)
packages+=(iftop)
packages+=(openssh-server)
packages+=(screen)
packages+=(sysstat)
packages+=(unzip)
packages+=(vim)
packages+=(xfsprogs)
packages+=(build-essential)
packages+=(ruby-dev)
packages+=(facter)

for pkg in ${packages[@]}; do
    @test "Check $pkg installed" {
        output=$(sudo dpkg -l | grep -i $pkg)
        [ $? -eq 0 ]
    }
done

This only yields one test, the last test in the array.

@miroswan This is a duplicate of #136. I answered the question there.