cli: option to auto-accept files (#2540)

* cli: option to auto-accept files

* auto-accept works

* test

* add missing field
This commit is contained in:
Evgeny Poberezkin authored and GitHub committed 2023-06-16 13:43:06 +01:00
1 parent c29c3179a0
commit 46c6f5e615
6 files changed
+60 -9

No files matched your search

+1
View File
@@ -74,6 +74,7 @@ testOpts =
optFilesFolder = Nothing,
showReactions = True,
allowInstantFiles = True,
autoAcceptFileSize = 0,
muteNotifications = True,
maintenance = False
}
+28
View File
@@ -1,3 +1,4 @@
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PostfixOperators #-}
@@ -68,6 +69,7 @@ chatFileTests = do
xit' "receive file marked to receive on chat start" testXFTPMarkToReceive
it "error receiving file" testXFTPRcvError
it "cancel receiving file, repeat receive" testXFTPCancelRcvRepeat
it "should accept file automatically with CLI option" testAutoAcceptFile
runTestFileTransfer :: HasCallStack => TestCC -> TestCC -> IO ()
runTestFileTransfer alice bob = do
@@ -1386,6 +1388,32 @@ testXFTPCancelRcvRepeat =
where
cfg = testCfg {xftpFileConfig = Just $ XFTPFileConfig {minFileSize = 0}, tempDir = Just "./tests/tmp"}
testAutoAcceptFile :: HasCallStack => FilePath -> IO ()
testAutoAcceptFile =
testChatCfgOpts2 cfg opts aliceProfile bobProfile $ \alice bob -> withXFTPServer $ do
connectUsers alice bob
bob ##> "/_files_folder ./tests/tmp/bob_files"
bob <## "ok"
alice #> "/f @bob ./tests/fixtures/test.jpg"
alice <## "use /fc 1 to cancel sending"
alice <## "completed uploading file 1 (test.jpg) for bob"
bob <# "alice> sends file test.jpg (136.5 KiB / 139737 bytes)"
bob <## "use /fr 1 [<dir>/ | <path>] to receive it"
bob <## "saving file 1 from alice to test.jpg"
bob <## "started receiving file 1 (test.jpg) from alice"
bob <## "completed receiving file 1 (test.jpg) from alice"
(bob </)
alice #> "/f @bob ./tests/fixtures/test_1MB.pdf"
alice <## "use /fc 2 to cancel sending"
alice <## "completed uploading file 2 (test_1MB.pdf) for bob"
bob <# "alice> sends file test_1MB.pdf (1017.7 KiB / 1042157 bytes)"
bob <## "use /fr 2 [<dir>/ | <path>] to receive it"
-- no auto accept for large files
(bob </)
where
cfg = testCfg {xftpFileConfig = Just $ XFTPFileConfig {minFileSize = 0}, tempDir = Just "./tests/tmp"}
opts = (testOpts :: ChatOpts) {autoAcceptFileSize = 200000}
xftpCLI :: [String] -> IO [String]
xftpCLI params = lines <$> capture_ (withArgs params xftpClientCLI)