-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Additional tests checking if files exists when using --database and --state-dir options #413
Conversation
d8ddee2
to
24af62e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice that we test this. Some remark to make the code a bit more concise and digest 👍
describe "SERVER - cardano-wallet server" $ do | ||
it "SERVER - Can start cardano-wallet server without --database" $ \_ -> do | ||
let cardanoWalletServer = Command | ||
"cardano-wallet" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that we should use stack -- exec cardano-wallet
and not cardano-wallet
as the latter requires the software to have been installed. Which isn't usually the case when tests are ran, so it's really easy to just run them on a wrong version.
let cardanoWalletServer = Command | ||
"cardano-wallet" | ||
[ "server" | ||
, "--random-port" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd remove the --random-port
from the tests since it's completely unrelated and this is a totally optional argument.
Inherit | ||
expectCmdStarts cardanoWalletServer | ||
|
||
w1 <- doesFileExist dbFile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
w1 <- doesFileExist dbFile | |
doesFileExist dbFile `shouldReturn` False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that was my first choice but:
/home/piotr/wb/cardano-wallet/lib/http-bridge/test/integration/Cardano/LauncherSpec.hs:46:71: error:
• Couldn't match expected type ‘IO Bool’ with actual type ‘Bool’
• In the second argument of ‘shouldBe’, namely ‘True’
In a stmt of a 'do' block:
(doesFileExist (stateDir ++ "/wallet.db-wal")) `shouldBe` True
In the second argument of ‘($)’, namely
‘do let cardanoWalletLauncher
= Command "cardano-wallet-launcher" ... (return ()) Inherit
expectCmdStarts cardanoWalletLauncher
d1 <- doesDirectoryExist stateDir
d2 <- doesDirectoryExist (stateDir ++ "/testnet")
....’
|
46 | (doesFileExist (stateDir ++ "/wallet.db-wal")) `shouldBe` True
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure to get your point here 😅 ? You example uses shouldBe
, whereas I suggested shouldReturn
(exactly because shouldBe
works with raw / unwrapped values, but shouldReturn
works with values inside a Monad
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ooh, gotcha! (note to self: don't respond to comments after midnight, or... at least, proof read the next day...)
w3 <- doesFileExist (dbFile ++ "-wal") | ||
w1 `shouldBe` True | ||
w2 `shouldBe` True | ||
w3 `shouldBe` True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same remark as before 👍
lib/core/test/integration/Test/Integration/Scenario/CLI/Server.hs
Outdated
Show resolved
Hide resolved
it "LAUNCHER - Can start launcher against testnet with --state-dir" $ do | ||
let cardanoWalletLauncher = Command | ||
"cardano-wallet-launcher" | ||
[ "--http-bridge-port", "8080" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depending on which of this one or #414 goes first, we'll have to update this to use the launch
command instead.
Oh! I also added |
24af62e
to
ca24707
Compare
@KtorZ, @rvl - I rebased and pushed review remarks. @rvl - I must have rebased carelessly because I removed your contents of |
w2 `shouldBe` True | ||
w3 `shouldBe` True | ||
where | ||
dbFile = "./test/data/test-DB-File" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rvl's version was using temporary random directory which has the nice side effect of not cluttering the development environment and avoid file conflicts between multiple runs (because for some reasons / failures, the tear down code wouldn't run).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(because for some reasons / failures, the tear down code wouldn't run).
I suppose after_ tearDown
should run no matter if test fails or passes?
Also @rvl's tests where for the launch
and --state-dir
not for serve
and --database
(https://github.com/input-output-hk/cardano-wallet/blob/master/lib/core/test/integration/Test/Integration/Scenario/CLI/Server.hs#L28-L39)
In any case I can bring temporary dir back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose after_ tearDown should run no matter if test fails or passes?
Provided the tear down code works as expected and removes files where they ought to be 😬 ... Perhaps files are already there and are created elsewhere, so the test doesn't test anything ? The good thing with taking a random file location everytime is that, we are "sure" nothing was there before, no matter what and we can eliminate false positives.
Although, that should also hold for the CI environment (which is supposedly, free of any build and tests artifacts), but it's not like we've never mistakenly committed test files and had them available in the integration environment 🙄 ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, added temp directory for launch
and serve
tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
08a6c09
to
c557058
Compare
…g if <file>'s are created
…ng if <dir> and contents are created
c557058
to
e061f7f
Compare
Issue Number
Overview
cardano-wallet server --database <filepath>
cardano-wallet-launcher --state-dir <filepath>
Comments
cardano-wallet-launcher
tests can be easily changed tocardano-wallet launcher
after #368.