packages feed

hadolint-2.1.0: test/DL3000.hs

module DL3000 (tests) where

import Helpers
import Test.Hspec


tests :: SpecWith ()
tests = do
  let ?rulesConfig = mempty
  describe "DL3000 - Use absolute WORKDIR." $ do
    it "workdir relative" $ ruleCatches "DL3000" "WORKDIR relative/dir"
    it "workdir absolute" $ ruleCatchesNot "DL3000" "WORKDIR /usr/local"
    it "workdir variable" $ ruleCatchesNot "DL3000" "WORKDIR ${work}"
    it "workdir relative single quotes" $ ruleCatches "DL3000" "WORKDIR \'relative/dir\'"
    it "workdir absolute single quotes" $ ruleCatchesNot "DL3000" "WORKDIR \'/usr/local\'"
    -- no test for variable/single quotes since the variable would not expand.
    it "workdir relative double quotes" $ ruleCatches "DL3000" "WORKDIR \"relative/dir\""
    it "workdir absolute double quotes" $ ruleCatchesNot "DL3000" "WORKDIR \"/usr/local\""
    it "workdir variable double quotes" $ ruleCatchesNot "DL3000" "WORKDIR \"${dir}\""
    --
    it "workdir absolute windows" $ ruleCatchesNot "DL3000" "WORKDIR \'C:\\\'"
    it "workdir absolute windows quotes" $ ruleCatchesNot "DL3000" "WORKDIR \"C:\\\""
    it "workdir absolute windows alternative" $
      ruleCatchesNot "DL3000" "WORKDIR C:/"
    it "workdir absolute windows quotes alternative" $
      ruleCatchesNot "DL3000" "WORKDIR \"C:/\""