|
| 1 | +{-# LANGUAGE FlexibleContexts #-} |
| 2 | + |
| 3 | + |
1 | 4 | -- | Check namespace consistencies agains configurations |
2 | 5 | module Test.Cardano.Tracing.NewTracing.Consistency (tests) where |
3 | 6 |
|
4 | 7 | import Cardano.Node.Tracing.Consistency (checkNodeTraceConfiguration) |
5 | 8 |
|
6 | | -import Control.Monad.IO.Class (liftIO) |
| 9 | +import Control.Monad.IO.Class (MonadIO, liftIO) |
7 | 10 | import Data.Text |
| 11 | +import System.Directory (canonicalizePath) |
| 12 | +import System.FilePath ((</>)) |
8 | 13 |
|
9 | 14 | import Hedgehog (Property) |
10 | 15 | import qualified Hedgehog as H |
11 | | -import qualified Hedgehog.Extras.Test.Base as H.Base |
| 16 | +import qualified Hedgehog.Extras.Test.Base as H |
| 17 | +import qualified Hedgehog.Extras.Test.Process as H |
12 | 18 | import Hedgehog.Internal.Property (PropertyName (PropertyName)) |
13 | 19 |
|
14 | | -tests :: IO Bool |
15 | | -tests = H.checkSequential |
| 20 | +tests :: MonadIO m => m Bool |
| 21 | +tests = do |
| 22 | + H.checkSequential |
16 | 23 | $ H.Group "Configuration Consistency tests" |
17 | | - $ test |
18 | | - <$> [ ( [] |
19 | | - -- This file name shoud reference the current standard config with new tracing |
20 | | - , "mainnet-config-new-tracing.json" |
21 | | - , configPrefix) |
22 | | - , ( [] |
23 | | - , "goodConfig.yaml" |
24 | | - , testPrefix) |
25 | | - , ( [ "Config namespace error: Illegal namespace ChainDB.CopyToImmutableDBEvent2.CopiedBlockToImmutableDB" |
26 | | - , "Config namespace error: Illegal namespace SubscriptionDNS" |
27 | | - ] |
28 | | - , "badConfig.yaml" |
29 | | - , testPrefix) |
30 | | - ] |
| 24 | + $ Prelude.map test |
| 25 | + [ ( [] |
| 26 | + -- This file name shoud reference the current standard config with new tracing |
| 27 | + , "mainnet-config-new-tracing.json" |
| 28 | + , configPrefix) |
| 29 | + , ( [] |
| 30 | + , "goodConfig.yaml" |
| 31 | + , testPrefix) |
| 32 | + , ( [ "Config namespace error: Illegal namespace ChainDB.CopyToImmutableDBEvent2.CopiedBlockToImmutableDB" |
| 33 | + , "Config namespace error: Illegal namespace SubscriptionDNS" |
| 34 | + ] |
| 35 | + , "badConfig.yaml" |
| 36 | + , testPrefix) |
| 37 | + ] |
31 | 38 | where |
32 | 39 | test (actualValue, goldenBaseName, prefix) = |
33 | 40 | (PropertyName goldenBaseName, goldenTestJSON actualValue goldenBaseName prefix) |
34 | 41 |
|
35 | 42 |
|
36 | | -goldenTestJSON :: [Text] -> FilePath -> FilePath -> Property |
37 | | -goldenTestJSON expectedOutcome goldenFileBaseName prefix = |
| 43 | +goldenTestJSON :: [Text] -> FilePath -> (FilePath -> IO FilePath) -> Property |
| 44 | +goldenTestJSON expectedOutcome goldenFileBaseName prefixFunc = |
38 | 45 | H.withTests 1 $ H.withShrinks 0 $ H.property $ do |
39 | | - goldenFp <- H.Base.note $ prefix <> goldenFileBaseName |
| 46 | + basePath <- H.getProjectBase |
| 47 | + prefixPath <- liftIO $ prefixFunc basePath |
| 48 | + goldenFp <- H.note $ prefixPath </> goldenFileBaseName |
40 | 49 | actualValue <- liftIO $ checkNodeTraceConfiguration goldenFp |
41 | 50 | actualValue H.=== expectedOutcome |
42 | 51 |
|
43 | 52 |
|
44 | | -configPrefix :: FilePath |
45 | | -configPrefix = "../configuration/cardano/" |
| 53 | +configPrefix :: FilePath -> IO FilePath |
| 54 | +configPrefix projectBase = do |
| 55 | + base <- canonicalizePath projectBase |
| 56 | + return $ base </> "configuration/cardano" |
46 | 57 |
|
47 | | -testPrefix :: FilePath |
48 | | -testPrefix = "test/Test/Cardano/Tracing/NewTracing/data/" |
| 58 | +testPrefix :: FilePath -> IO FilePath |
| 59 | +testPrefix _ = pure "test/Test/Cardano/Tracing/NewTracing/data/" |
0 commit comments