-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #88 from m-ildefons/fix/hadolint-893-healthcheck-f…
…ractional-args fixes hadolint/hadolint#893
- Loading branch information
Showing
6 changed files
with
95 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
module Language.Docker.ParseHealthcheckSpec where | ||
|
||
import Data.Default.Class (def) | ||
import Language.Docker.Syntax | ||
import Test.Hspec | ||
import TestHelper | ||
import qualified Data.Set as Set | ||
import qualified Data.Text as Text | ||
|
||
|
||
spec :: Spec | ||
spec = do | ||
describe "parse HEALTHCHECK" $ do | ||
it "parse healthcheck with interval" $ | ||
assertAst | ||
"HEALTHCHECK --interval=5m \\\nCMD curl -f http://localhost/" | ||
[ Healthcheck $ | ||
Check $ | ||
CheckArgs "curl -f http://localhost/" (Just 300) Nothing Nothing Nothing | ||
] | ||
it "parse healthcheck with retries" $ | ||
assertAst | ||
"HEALTHCHECK --retries=10 CMD curl -f http://localhost/" | ||
[ Healthcheck $ | ||
Check $ | ||
CheckArgs "curl -f http://localhost/" Nothing Nothing Nothing (Just $ Retries 10) | ||
] | ||
it "parse healthcheck with timeout" $ | ||
assertAst | ||
"HEALTHCHECK --timeout=10s CMD curl -f http://localhost/" | ||
[ Healthcheck $ | ||
Check $ | ||
CheckArgs "curl -f http://localhost/" Nothing (Just 10) Nothing Nothing | ||
] | ||
it "parse healthcheck with start-period" $ | ||
assertAst | ||
"HEALTHCHECK --start-period=2m CMD curl -f http://localhost/" | ||
[ Healthcheck $ | ||
Check $ | ||
CheckArgs "curl -f http://localhost/" Nothing Nothing (Just 120) Nothing | ||
] | ||
it "parse healthcheck with all flags" $ | ||
assertAst | ||
"HEALTHCHECK --start-period=2s --timeout=1m --retries=3 --interval=5s CMD curl -f http://localhost/" | ||
[ Healthcheck $ | ||
Check $ | ||
CheckArgs | ||
"curl -f http://localhost/" | ||
(Just 5) | ||
(Just 60) | ||
(Just 2) | ||
(Just $ Retries 3) | ||
] | ||
it "parse healthcheck with no flags" $ | ||
assertAst | ||
"HEALTHCHECK CMD curl -f http://localhost/" | ||
[ Healthcheck $ | ||
Check $ | ||
CheckArgs "curl -f http://localhost/" Nothing Nothing Nothing Nothing | ||
] | ||
|
||
it "fractional arguments to flags" $ | ||
let file = | ||
Text.unlines | ||
[ "HEALTHCHECK \\", | ||
" --interval=0.5s \\", | ||
" --timeout=0.1s \\", | ||
" --start-period=0.2s \\", | ||
" CMD curl -f http://localhost" | ||
] | ||
in assertAst | ||
file | ||
[ Healthcheck $ | ||
Check $ | ||
CheckArgs | ||
"curl -f http://localhost" | ||
( Just 0.5 ) | ||
( Just 0.10000000149 ) | ||
( Just 0.20000000298 ) | ||
Nothing | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters