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-assert and bats-file libraries not actually loaded #33

Open
rfay opened this issue Sep 17, 2023 · 2 comments
Open

bats-assert and bats-file libraries not actually loaded #33

rfay opened this issue Sep 17, 2023 · 2 comments
Assignees

Comments

@rfay
Copy link
Member

rfay commented Sep 17, 2023

Although we brew install bats-aassert bats-file we don't actually load them properly, so they're not available for use. brew info bats-assert for example tells us:

==> Caveats

To load the bats-assert lib in your bats test:

    load '/home/linuxbrew/.linuxbrew/lib/bats-support/load.bash'
    load '/home/linuxbrew/.linuxbrew/lib/bats-assert/load.bash'
==> Caveats

To load the bats-file lib in your bats test:

    load '/home/linuxbrew/.linuxbrew/lib/bats-support/load.bash'
    load '/home/linuxbrew/.linuxbrew/lib/bats-file/load.bash'
@julienloizelet julienloizelet self-assigned this Sep 19, 2023
@julienloizelet
Copy link
Contributor

Hi @rfay ,

After some search, I found that the "load" call must be made in the test.bats file itself ...

For example, I added :

TEST_BREW_PREFIX="$(brew --prefix)"
load "${TEST_BREW_PREFIX}/lib/bats-support/load.bash"
load "${TEST_BREW_PREFIX}/lib/bats-assert/load.bash"

at the beginning of a tests.bats file and the, the following test works :

@test 'assert_equal()' {
  assert_equal 'have' 'have'
}

Adding this these lines in a bats file is what is explained here: https://github.com/ztombol/bats-docs#loading

Maybe you know another way to load the files (I failed to try some source "/home/linuxbrew/.linuxbrew/lib/bats-support/load.bash" manually ) ?

If not, in my opinion, we should just update the ddev-addon-template README to speak about this.

@rfay rfay transferred this issue from ddev/github-action-add-on-test Sep 19, 2023
@rfay
Copy link
Member Author

rfay commented Sep 19, 2023

Moved it over, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants