GithubHelp home page GithubHelp logo

Comments (3)

nkubala avatar nkubala commented on June 2, 2024

Hey @AlbertoSH, thanks for filing and sorry for the late reply on this one.

container-structure-test doesn't currently support environment variable substitution in the test spec itself, so you won't be able to use any env vars as part of your test args/output. However, what you're trying to do is still possible using the metadataTest:

schemaVersion: 2.0.0

globalEnvVars:
  - key: FOO
    value: test_value

metadataTest:
  env:
    - key: PATH
      value: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    - key: FOO
      value: test_value

You can specify all your env vars here and check to be sure they're set to the correct value. It's also worth noting that this will NOT let you check variables set by the OS at boot or login time, i.e. $HOME, as these are not part of the container config.

All that said, I did actually find an issue with setting the env vars outside of the CommandTests: opened an issue for that here.

from container-structure-test.

AlbertoSH avatar AlbertoSH commented on June 2, 2024

Yes, I know that I can test the env variables with the metadataTest but my use case was more intended to check that some software was installed and its executable was added to the PATH. So my real test is something like:

schemaVersion: "2.0.0"
globalEnvVars:
  - name: "some specific software version"
    envVars:
      - key: "PATH"
        value: "$PATH:$HOME/some/dir"
    command: "someExecutableAvailableInPath"
    args: ["some", "args"]
    expectedOutput: ["Version X"]

In the end I got a similar result with:

schemaVersion: "2.0.0"
globalEnvVars:
  - name: "some specific software version"
    # PATH redefinition not needed since it's set in .bashrc
    command: "bash"
    args: ["-cl", "someExecutableAvailableInPath some args"]
    expectedOutput: ["Version X"]

But it feels like an ugly workaround

from container-structure-test.

nkubala avatar nkubala commented on June 2, 2024

@AlbertoSH this should now be supported via #130. I'll get the next release out ASAP

from container-structure-test.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.