Skip to content

Commit

Permalink
Restructure ConfigSpec
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrisbin committed Oct 21, 2024
1 parent 10fdb1a commit 14fd50a
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions test/Restyler/ConfigSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,29 @@ import UnliftIO.Temporary (withSystemTempFile)
spec :: Spec
spec = do
context "options" $ do
context "flags used by actions/run" $ do
let checkOption name p = do
it ("supports --" <> name) $ do
config <- loadTestConfig ["--" <> name, "Foo.hs"] [] []
p config `shouldBe` True
let checkOption name p = do
it ("supports --" <> name) $ do
config <- loadTestConfig ["--" <> name, "Foo.hs"] [] []
p config `shouldBe` True

checkOption "debug" $ \config ->
let
settings = modLogSettings config.logSettings defaultLogSettings
logsLevel = shouldLogLevel settings ""
in
logsLevel LevelDebug && not (logsLevel $ LevelOther "trace")
checkOption "debug" $ \config ->
let
settings = modLogSettings config.logSettings defaultLogSettings
logsLevel = shouldLogLevel settings ""
in
logsLevel LevelDebug && not (logsLevel $ LevelOther "trace")

checkOption "fail-on-differences" (.failOnDifferences)
checkOption "fail-on-differences" (.failOnDifferences)

checkOption "image-cleanup" (.imageCleanup)
checkOption "image-cleanup" (.imageCleanup)

checkOption "no-commit" (.noCommit)
checkOption "no-commit" (.noCommit)

checkOption "no-pull" (.noPull)
checkOption "no-pull" (.noPull)

it "supports --manifest" $ do
config <- loadTestConfig ["--manifest", "/tmp/x.yaml", "Foo.hs"] [] []
config.restylersManifest `shouldBe` Just $(mkAbsFile "/tmp/x.yaml")
it "supports --manifest" $ do
config <- loadTestConfig ["--manifest", "/tmp/x.yaml", "Foo.hs"] [] []
config.restylersManifest `shouldBe` Just $(mkAbsFile "/tmp/x.yaml")

context "configuration" $ do
-- This test is a maintainence burden, in that when config/default.yaml
Expand Down Expand Up @@ -197,11 +196,11 @@ spec = do
it "rejects path-less URLs if path is not given" $ do
result <-
loadTestConfigEither
["Bar.hs"]
[]
[ "remote_files:"
, " - https://example.com/"
]
[]
["Bar.hs"]

void result `shouldSatisfy` isLeft

Expand Down

0 comments on commit 14fd50a

Please sign in to comment.