You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "silver-ymz (via GitHub)" <gi...@apache.org> on 2023/06/18 05:09:32 UTC
[GitHub] [incubator-opendal] silver-ymz opened a new pull request, #2482: feat(bindings/haskell): add `Monad` wrapper
silver-ymz opened a new pull request, #2482:
URL: https://github.com/apache/incubator-opendal/pull/2482
Update:
- add `MonadOperation` typeclass to provide flexible API
- add `OpMonad` to provide basic `Monad` for user
- add tests `testMonad` and `testError`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-opendal] Xuanwo commented on a diff in pull request #2482: feat(bindings/haskell): add `Monad` wrapper
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on code in PR #2482:
URL: https://github.com/apache/incubator-opendal/pull/2482#discussion_r1233193209
##########
bindings/haskell/test/BasicTest.hs:
##########
@@ -27,25 +28,59 @@ basicTests :: TestTree
basicTests =
testGroup
"Basic Tests"
- [ testCase "testBasicOperation" testBasicOperation
+ [ testCase "testBasicOperation" testRawOperation
+ , testCase "testMonad" testMonad
+ , testCase "testError" testError
]
-testBasicOperation :: Assertion
-testBasicOperation = do
+testRawOperation :: Assertion
+testRawOperation = do
Right op <- newOp "fs" $ HashMap.fromList [("root", "/tmp/opendal-test")]
- writeOp op "key1" "value1" >>= (@?= Right ())
- writeOp op "key2" "value2" >>= (@?= Right ())
- readOp op "key1" >>= (@?= Right "value1")
- readOp op "key2" >>= (@?= Right "value2")
- isExistOp op "key1" >>= (@?= Right True)
- isExistOp op "key2" >>= (@?= Right True)
- createDirOp op "dir1/" >>= (@?= Right ())
- isExistOp op "dir1/" >>= (@?= Right True)
- copyOp op "key1" "key3" >>= (@?= Right ())
- isExistOp op "key3" >>= (@?= Right True)
- isExistOp op "key1" >>= (@?= Right True)
- renameOp op "key2" "key4" >>= (@?= Right ())
- isExistOp op "key4" >>= (@?= Right True)
- isExistOp op "key2" >>= (@?= Right False)
- deleteOp op "key1" >>= (@?= Right ())
- isExistOp op "key1" >>= (@?= Right False)
\ No newline at end of file
+ writeOpRaw op "key1" "value1" >>= (@?= Right ())
+ writeOpRaw op "key2" "value2" >>= (@?= Right ())
+ readOpRaw op "key1" >>= (@?= Right "value1")
+ readOpRaw op "key2" >>= (@?= Right "value2")
+ isExistOpRaw op "key1" >>= (@?= Right True)
+ isExistOpRaw op "key2" >>= (@?= Right True)
+ createDirOpRaw op "dir1/" >>= (@?= Right ())
+ isExistOpRaw op "dir1/" >>= (@?= Right True)
+ copyOpRaw op "key1" "key3" >>= (@?= Right ())
+ isExistOpRaw op "key3" >>= (@?= Right True)
+ isExistOpRaw op "key1" >>= (@?= Right True)
+ renameOpRaw op "key2" "key4" >>= (@?= Right ())
+ isExistOpRaw op "key4" >>= (@?= Right True)
+ isExistOpRaw op "key2" >>= (@?= Right False)
+ deleteOpRaw op "key1" >>= (@?= Right ())
+ isExistOpRaw op "key1" >>= (@?= Right False)
+
+testMonad :: Assertion
+testMonad = do
+ Right op <- newOp "fs" $ HashMap.fromList [("root", "/tmp/opendal-test2")]
+ runOp op operation >>= (@?= Right ())
+ where
+ operation = do
+ writeOp "key1" "value1"
+ writeOp "key2" "value2"
+ readOp "key1" >>= liftIO . (@?= "value1")
+ readOp "key2" >>= liftIO . (@?= "value2")
+ isExistOp "key1" >>= liftIO . (@?= True)
+ isExistOp "key2" >>= liftIO . (@?= True)
+ createDirOp "dir1/"
+ isExistOp "dir1/" >>= liftIO . (@?= True)
+ copyOp "key1" "key3"
+ isExistOp "key3" >>= liftIO . (@?= True)
+ isExistOp "key1" >>= liftIO . (@?= True)
+ renameOp "key2" "key4"
+ isExistOp "key4" >>= liftIO . (@?= True)
+ isExistOp "key2" >>= liftIO . (@?= False)
+ deleteOp "key1"
+ isExistOp "key1" >>= liftIO . (@?= False)
+
+testError :: Assertion
+testError = do
+ Right op <- newOp "fs" $ HashMap.fromList [("root", "/tmp/opendal-test3")]
Review Comment:
I prefer to test again memory service to avoid affected by env. For example, this test will not pass on windows.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-opendal] Xuanwo merged pull request #2482: feat(bindings/haskell): add `Monad` wrapper
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo merged PR #2482:
URL: https://github.com/apache/incubator-opendal/pull/2482
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-opendal] silver-ymz commented on a diff in pull request #2482: feat(bindings/haskell): add `Monad` wrapper
Posted by "silver-ymz (via GitHub)" <gi...@apache.org>.
silver-ymz commented on code in PR #2482:
URL: https://github.com/apache/incubator-opendal/pull/2482#discussion_r1233201086
##########
bindings/haskell/test/BasicTest.hs:
##########
@@ -27,25 +28,76 @@ basicTests :: TestTree
basicTests =
testGroup
"Basic Tests"
- [ testCase "testBasicOperation" testBasicOperation
+ [ testCaseSteps "testBasicOperation" testRawOperation
+ , testCaseSteps "testMonad" testMonad
+ , testCaseSteps "testError" testError
]
-testBasicOperation :: Assertion
-testBasicOperation = do
+testRawOperation :: (String -> IO ()) -> Assertion
+testRawOperation step = do
+ step "test fs"
Right op <- newOp "fs" $ HashMap.fromList [("root", "/tmp/opendal-test")]
- writeOp op "key1" "value1" >>= (@?= Right ())
- writeOp op "key2" "value2" >>= (@?= Right ())
- readOp op "key1" >>= (@?= Right "value1")
- readOp op "key2" >>= (@?= Right "value2")
- isExistOp op "key1" >>= (@?= Right True)
- isExistOp op "key2" >>= (@?= Right True)
- createDirOp op "dir1/" >>= (@?= Right ())
- isExistOp op "dir1/" >>= (@?= Right True)
- copyOp op "key1" "key3" >>= (@?= Right ())
- isExistOp op "key3" >>= (@?= Right True)
- isExistOp op "key1" >>= (@?= Right True)
- renameOp op "key2" "key4" >>= (@?= Right ())
- isExistOp op "key4" >>= (@?= Right True)
- isExistOp op "key2" >>= (@?= Right False)
- deleteOp op "key1" >>= (@?= Right ())
- isExistOp op "key1" >>= (@?= Right False)
\ No newline at end of file
+ writeOpRaw op "key1" "value1" >>= (@?= Right ())
+ writeOpRaw op "key2" "value2" >>= (@?= Right ())
+ readOpRaw op "key1" >>= (@?= Right "value1")
+ readOpRaw op "key2" >>= (@?= Right "value2")
+ isExistOpRaw op "key1" >>= (@?= Right True)
+ isExistOpRaw op "key2" >>= (@?= Right True)
+ createDirOpRaw op "dir1/" >>= (@?= Right ())
+ isExistOpRaw op "dir1/" >>= (@?= Right True)
+ copyOpRaw op "key1" "key3" >>= (@?= Right ())
+ isExistOpRaw op "key3" >>= (@?= Right True)
+ isExistOpRaw op "key1" >>= (@?= Right True)
+ renameOpRaw op "key2" "key4" >>= (@?= Right ())
+ isExistOpRaw op "key4" >>= (@?= Right True)
+ isExistOpRaw op "key2" >>= (@?= Right False)
+ deleteOpRaw op "key1" >>= (@?= Right ())
+ isExistOpRaw op "key1" >>= (@?= Right False)
+ step "test memory"
+ Right op2 <- newOp "memory" HashMap.empty
+ writeOpRaw op2 "key1" "value1" >>= (@?= Right ())
+ writeOpRaw op2 "key2" "value2" >>= (@?= Right ())
+ readOpRaw op2 "key1" >>= (@?= Right "value1")
+ readOpRaw op2 "key2" >>= (@?= Right "value2")
+ isExistOpRaw op2 "key1" >>= (@?= Right True)
+ isExistOpRaw op2 "key2" >>= (@?= Right True)
+ createDirOpRaw op2 "dir1/" >>= (@?= Right ())
+ isExistOpRaw op2 "dir1/" >>= (@?= Right True)
+ deleteOpRaw op2 "key1" >>= (@?= Right ())
+ isExistOpRaw op2 "key1" >>= (@?= Right False)
+
+testMonad :: (String -> IO ()) -> Assertion
+testMonad step = do
+ step "test fs"
+ Right op <- newOp "fs" $ HashMap.fromList [("root", "/tmp/opendal-test2")]
Review Comment:
This has already added tests for memory in new commit.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-opendal] Xuanwo commented on a diff in pull request #2482: feat(bindings/haskell): add `Monad` wrapper
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on code in PR #2482:
URL: https://github.com/apache/incubator-opendal/pull/2482#discussion_r1233200875
##########
bindings/haskell/test/BasicTest.hs:
##########
@@ -27,25 +28,76 @@ basicTests :: TestTree
basicTests =
testGroup
"Basic Tests"
- [ testCase "testBasicOperation" testBasicOperation
+ [ testCaseSteps "testBasicOperation" testRawOperation
+ , testCaseSteps "testMonad" testMonad
+ , testCaseSteps "testError" testError
]
-testBasicOperation :: Assertion
-testBasicOperation = do
+testRawOperation :: (String -> IO ()) -> Assertion
+testRawOperation step = do
+ step "test fs"
Review Comment:
so does this.
##########
bindings/haskell/test/BasicTest.hs:
##########
@@ -27,25 +28,76 @@ basicTests :: TestTree
basicTests =
testGroup
"Basic Tests"
- [ testCase "testBasicOperation" testBasicOperation
+ [ testCaseSteps "testBasicOperation" testRawOperation
+ , testCaseSteps "testMonad" testMonad
+ , testCaseSteps "testError" testError
]
-testBasicOperation :: Assertion
-testBasicOperation = do
+testRawOperation :: (String -> IO ()) -> Assertion
+testRawOperation step = do
+ step "test fs"
Right op <- newOp "fs" $ HashMap.fromList [("root", "/tmp/opendal-test")]
- writeOp op "key1" "value1" >>= (@?= Right ())
- writeOp op "key2" "value2" >>= (@?= Right ())
- readOp op "key1" >>= (@?= Right "value1")
- readOp op "key2" >>= (@?= Right "value2")
- isExistOp op "key1" >>= (@?= Right True)
- isExistOp op "key2" >>= (@?= Right True)
- createDirOp op "dir1/" >>= (@?= Right ())
- isExistOp op "dir1/" >>= (@?= Right True)
- copyOp op "key1" "key3" >>= (@?= Right ())
- isExistOp op "key3" >>= (@?= Right True)
- isExistOp op "key1" >>= (@?= Right True)
- renameOp op "key2" "key4" >>= (@?= Right ())
- isExistOp op "key4" >>= (@?= Right True)
- isExistOp op "key2" >>= (@?= Right False)
- deleteOp op "key1" >>= (@?= Right ())
- isExistOp op "key1" >>= (@?= Right False)
\ No newline at end of file
+ writeOpRaw op "key1" "value1" >>= (@?= Right ())
+ writeOpRaw op "key2" "value2" >>= (@?= Right ())
+ readOpRaw op "key1" >>= (@?= Right "value1")
+ readOpRaw op "key2" >>= (@?= Right "value2")
+ isExistOpRaw op "key1" >>= (@?= Right True)
+ isExistOpRaw op "key2" >>= (@?= Right True)
+ createDirOpRaw op "dir1/" >>= (@?= Right ())
+ isExistOpRaw op "dir1/" >>= (@?= Right True)
+ copyOpRaw op "key1" "key3" >>= (@?= Right ())
+ isExistOpRaw op "key3" >>= (@?= Right True)
+ isExistOpRaw op "key1" >>= (@?= Right True)
+ renameOpRaw op "key2" "key4" >>= (@?= Right ())
+ isExistOpRaw op "key4" >>= (@?= Right True)
+ isExistOpRaw op "key2" >>= (@?= Right False)
+ deleteOpRaw op "key1" >>= (@?= Right ())
+ isExistOpRaw op "key1" >>= (@?= Right False)
+ step "test memory"
+ Right op2 <- newOp "memory" HashMap.empty
+ writeOpRaw op2 "key1" "value1" >>= (@?= Right ())
+ writeOpRaw op2 "key2" "value2" >>= (@?= Right ())
+ readOpRaw op2 "key1" >>= (@?= Right "value1")
+ readOpRaw op2 "key2" >>= (@?= Right "value2")
+ isExistOpRaw op2 "key1" >>= (@?= Right True)
+ isExistOpRaw op2 "key2" >>= (@?= Right True)
+ createDirOpRaw op2 "dir1/" >>= (@?= Right ())
+ isExistOpRaw op2 "dir1/" >>= (@?= Right True)
+ deleteOpRaw op2 "key1" >>= (@?= Right ())
+ isExistOpRaw op2 "key1" >>= (@?= Right False)
+
+testMonad :: (String -> IO ()) -> Assertion
+testMonad step = do
+ step "test fs"
+ Right op <- newOp "fs" $ HashMap.fromList [("root", "/tmp/opendal-test2")]
Review Comment:
Also need change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-opendal] silver-ymz commented on a diff in pull request #2482: feat(bindings/haskell): add `Monad` wrapper
Posted by "silver-ymz (via GitHub)" <gi...@apache.org>.
silver-ymz commented on code in PR #2482:
URL: https://github.com/apache/incubator-opendal/pull/2482#discussion_r1233202800
##########
bindings/haskell/test/BasicTest.hs:
##########
@@ -27,25 +28,76 @@ basicTests :: TestTree
basicTests =
testGroup
"Basic Tests"
- [ testCase "testBasicOperation" testBasicOperation
+ [ testCaseSteps "testBasicOperation" testRawOperation
+ , testCaseSteps "testMonad" testMonad
+ , testCaseSteps "testError" testError
]
-testBasicOperation :: Assertion
-testBasicOperation = do
+testRawOperation :: (String -> IO ()) -> Assertion
+testRawOperation step = do
+ step "test fs"
Right op <- newOp "fs" $ HashMap.fromList [("root", "/tmp/opendal-test")]
- writeOp op "key1" "value1" >>= (@?= Right ())
- writeOp op "key2" "value2" >>= (@?= Right ())
- readOp op "key1" >>= (@?= Right "value1")
- readOp op "key2" >>= (@?= Right "value2")
- isExistOp op "key1" >>= (@?= Right True)
- isExistOp op "key2" >>= (@?= Right True)
- createDirOp op "dir1/" >>= (@?= Right ())
- isExistOp op "dir1/" >>= (@?= Right True)
- copyOp op "key1" "key3" >>= (@?= Right ())
- isExistOp op "key3" >>= (@?= Right True)
- isExistOp op "key1" >>= (@?= Right True)
- renameOp op "key2" "key4" >>= (@?= Right ())
- isExistOp op "key4" >>= (@?= Right True)
- isExistOp op "key2" >>= (@?= Right False)
- deleteOp op "key1" >>= (@?= Right ())
- isExistOp op "key1" >>= (@?= Right False)
\ No newline at end of file
+ writeOpRaw op "key1" "value1" >>= (@?= Right ())
+ writeOpRaw op "key2" "value2" >>= (@?= Right ())
+ readOpRaw op "key1" >>= (@?= Right "value1")
+ readOpRaw op "key2" >>= (@?= Right "value2")
+ isExistOpRaw op "key1" >>= (@?= Right True)
+ isExistOpRaw op "key2" >>= (@?= Right True)
+ createDirOpRaw op "dir1/" >>= (@?= Right ())
+ isExistOpRaw op "dir1/" >>= (@?= Right True)
+ copyOpRaw op "key1" "key3" >>= (@?= Right ())
+ isExistOpRaw op "key3" >>= (@?= Right True)
+ isExistOpRaw op "key1" >>= (@?= Right True)
+ renameOpRaw op "key2" "key4" >>= (@?= Right ())
+ isExistOpRaw op "key4" >>= (@?= Right True)
+ isExistOpRaw op "key2" >>= (@?= Right False)
+ deleteOpRaw op "key1" >>= (@?= Right ())
+ isExistOpRaw op "key1" >>= (@?= Right False)
+ step "test memory"
+ Right op2 <- newOp "memory" HashMap.empty
+ writeOpRaw op2 "key1" "value1" >>= (@?= Right ())
+ writeOpRaw op2 "key2" "value2" >>= (@?= Right ())
+ readOpRaw op2 "key1" >>= (@?= Right "value1")
+ readOpRaw op2 "key2" >>= (@?= Right "value2")
+ isExistOpRaw op2 "key1" >>= (@?= Right True)
+ isExistOpRaw op2 "key2" >>= (@?= Right True)
+ createDirOpRaw op2 "dir1/" >>= (@?= Right ())
+ isExistOpRaw op2 "dir1/" >>= (@?= Right True)
+ deleteOpRaw op2 "key1" >>= (@?= Right ())
+ isExistOpRaw op2 "key1" >>= (@?= Right False)
+
+testMonad :: (String -> IO ()) -> Assertion
+testMonad step = do
+ step "test fs"
+ Right op <- newOp "fs" $ HashMap.fromList [("root", "/tmp/opendal-test2")]
Review Comment:
updated in new commit
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-opendal] Xuanwo commented on a diff in pull request #2482: feat(bindings/haskell): add `Monad` wrapper
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on code in PR #2482:
URL: https://github.com/apache/incubator-opendal/pull/2482#discussion_r1233201522
##########
bindings/haskell/test/BasicTest.hs:
##########
@@ -27,25 +28,76 @@ basicTests :: TestTree
basicTests =
testGroup
"Basic Tests"
- [ testCase "testBasicOperation" testBasicOperation
+ [ testCaseSteps "testBasicOperation" testRawOperation
+ , testCaseSteps "testMonad" testMonad
+ , testCaseSteps "testError" testError
]
-testBasicOperation :: Assertion
-testBasicOperation = do
+testRawOperation :: (String -> IO ()) -> Assertion
+testRawOperation step = do
+ step "test fs"
Right op <- newOp "fs" $ HashMap.fromList [("root", "/tmp/opendal-test")]
- writeOp op "key1" "value1" >>= (@?= Right ())
- writeOp op "key2" "value2" >>= (@?= Right ())
- readOp op "key1" >>= (@?= Right "value1")
- readOp op "key2" >>= (@?= Right "value2")
- isExistOp op "key1" >>= (@?= Right True)
- isExistOp op "key2" >>= (@?= Right True)
- createDirOp op "dir1/" >>= (@?= Right ())
- isExistOp op "dir1/" >>= (@?= Right True)
- copyOp op "key1" "key3" >>= (@?= Right ())
- isExistOp op "key3" >>= (@?= Right True)
- isExistOp op "key1" >>= (@?= Right True)
- renameOp op "key2" "key4" >>= (@?= Right ())
- isExistOp op "key4" >>= (@?= Right True)
- isExistOp op "key2" >>= (@?= Right False)
- deleteOp op "key1" >>= (@?= Right ())
- isExistOp op "key1" >>= (@?= Right False)
\ No newline at end of file
+ writeOpRaw op "key1" "value1" >>= (@?= Right ())
+ writeOpRaw op "key2" "value2" >>= (@?= Right ())
+ readOpRaw op "key1" >>= (@?= Right "value1")
+ readOpRaw op "key2" >>= (@?= Right "value2")
+ isExistOpRaw op "key1" >>= (@?= Right True)
+ isExistOpRaw op "key2" >>= (@?= Right True)
+ createDirOpRaw op "dir1/" >>= (@?= Right ())
+ isExistOpRaw op "dir1/" >>= (@?= Right True)
+ copyOpRaw op "key1" "key3" >>= (@?= Right ())
+ isExistOpRaw op "key3" >>= (@?= Right True)
+ isExistOpRaw op "key1" >>= (@?= Right True)
+ renameOpRaw op "key2" "key4" >>= (@?= Right ())
+ isExistOpRaw op "key4" >>= (@?= Right True)
+ isExistOpRaw op "key2" >>= (@?= Right False)
+ deleteOpRaw op "key1" >>= (@?= Right ())
+ isExistOpRaw op "key1" >>= (@?= Right False)
+ step "test memory"
+ Right op2 <- newOp "memory" HashMap.empty
+ writeOpRaw op2 "key1" "value1" >>= (@?= Right ())
+ writeOpRaw op2 "key2" "value2" >>= (@?= Right ())
+ readOpRaw op2 "key1" >>= (@?= Right "value1")
+ readOpRaw op2 "key2" >>= (@?= Right "value2")
+ isExistOpRaw op2 "key1" >>= (@?= Right True)
+ isExistOpRaw op2 "key2" >>= (@?= Right True)
+ createDirOpRaw op2 "dir1/" >>= (@?= Right ())
+ isExistOpRaw op2 "dir1/" >>= (@?= Right True)
+ deleteOpRaw op2 "key1" >>= (@?= Right ())
+ isExistOpRaw op2 "key1" >>= (@?= Right False)
+
+testMonad :: (String -> IO ()) -> Assertion
+testMonad step = do
+ step "test fs"
+ Right op <- newOp "fs" $ HashMap.fromList [("root", "/tmp/opendal-test2")]
Review Comment:
My suggestion is to avoid testing different services. The tests should only focus on the logic of the binding itself. Additionally, it's recommended to use a cheap and easy-to-run service for testing purposes. In this case, `memory` is the best option as it has no side effects and can be run on all platforms.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-opendal] silver-ymz commented on a diff in pull request #2482: feat(bindings/haskell): add `Monad` wrapper
Posted by "silver-ymz (via GitHub)" <gi...@apache.org>.
silver-ymz commented on code in PR #2482:
URL: https://github.com/apache/incubator-opendal/pull/2482#discussion_r1233201922
##########
bindings/haskell/test/BasicTest.hs:
##########
@@ -27,25 +28,76 @@ basicTests :: TestTree
basicTests =
testGroup
"Basic Tests"
- [ testCase "testBasicOperation" testBasicOperation
+ [ testCaseSteps "testBasicOperation" testRawOperation
+ , testCaseSteps "testMonad" testMonad
+ , testCaseSteps "testError" testError
]
-testBasicOperation :: Assertion
-testBasicOperation = do
+testRawOperation :: (String -> IO ()) -> Assertion
+testRawOperation step = do
+ step "test fs"
Right op <- newOp "fs" $ HashMap.fromList [("root", "/tmp/opendal-test")]
- writeOp op "key1" "value1" >>= (@?= Right ())
- writeOp op "key2" "value2" >>= (@?= Right ())
- readOp op "key1" >>= (@?= Right "value1")
- readOp op "key2" >>= (@?= Right "value2")
- isExistOp op "key1" >>= (@?= Right True)
- isExistOp op "key2" >>= (@?= Right True)
- createDirOp op "dir1/" >>= (@?= Right ())
- isExistOp op "dir1/" >>= (@?= Right True)
- copyOp op "key1" "key3" >>= (@?= Right ())
- isExistOp op "key3" >>= (@?= Right True)
- isExistOp op "key1" >>= (@?= Right True)
- renameOp op "key2" "key4" >>= (@?= Right ())
- isExistOp op "key4" >>= (@?= Right True)
- isExistOp op "key2" >>= (@?= Right False)
- deleteOp op "key1" >>= (@?= Right ())
- isExistOp op "key1" >>= (@?= Right False)
\ No newline at end of file
+ writeOpRaw op "key1" "value1" >>= (@?= Right ())
+ writeOpRaw op "key2" "value2" >>= (@?= Right ())
+ readOpRaw op "key1" >>= (@?= Right "value1")
+ readOpRaw op "key2" >>= (@?= Right "value2")
+ isExistOpRaw op "key1" >>= (@?= Right True)
+ isExistOpRaw op "key2" >>= (@?= Right True)
+ createDirOpRaw op "dir1/" >>= (@?= Right ())
+ isExistOpRaw op "dir1/" >>= (@?= Right True)
+ copyOpRaw op "key1" "key3" >>= (@?= Right ())
+ isExistOpRaw op "key3" >>= (@?= Right True)
+ isExistOpRaw op "key1" >>= (@?= Right True)
+ renameOpRaw op "key2" "key4" >>= (@?= Right ())
+ isExistOpRaw op "key4" >>= (@?= Right True)
+ isExistOpRaw op "key2" >>= (@?= Right False)
+ deleteOpRaw op "key1" >>= (@?= Right ())
+ isExistOpRaw op "key1" >>= (@?= Right False)
+ step "test memory"
+ Right op2 <- newOp "memory" HashMap.empty
+ writeOpRaw op2 "key1" "value1" >>= (@?= Right ())
+ writeOpRaw op2 "key2" "value2" >>= (@?= Right ())
+ readOpRaw op2 "key1" >>= (@?= Right "value1")
+ readOpRaw op2 "key2" >>= (@?= Right "value2")
+ isExistOpRaw op2 "key1" >>= (@?= Right True)
+ isExistOpRaw op2 "key2" >>= (@?= Right True)
+ createDirOpRaw op2 "dir1/" >>= (@?= Right ())
+ isExistOpRaw op2 "dir1/" >>= (@?= Right True)
+ deleteOpRaw op2 "key1" >>= (@?= Right ())
+ isExistOpRaw op2 "key1" >>= (@?= Right False)
+
+testMonad :: (String -> IO ()) -> Assertion
+testMonad step = do
+ step "test fs"
+ Right op <- newOp "fs" $ HashMap.fromList [("root", "/tmp/opendal-test2")]
Review Comment:
So should we only add tests for `memory`, and need to remove `fs` test?
`Memory` doesn't support `copy` and `rename` so that it can't cover all basic operations.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-opendal] Xuanwo commented on a diff in pull request #2482: feat(bindings/haskell): add `Monad` wrapper
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on code in PR #2482:
URL: https://github.com/apache/incubator-opendal/pull/2482#discussion_r1233202313
##########
bindings/haskell/test/BasicTest.hs:
##########
@@ -27,25 +28,76 @@ basicTests :: TestTree
basicTests =
testGroup
"Basic Tests"
- [ testCase "testBasicOperation" testBasicOperation
+ [ testCaseSteps "testBasicOperation" testRawOperation
+ , testCaseSteps "testMonad" testMonad
+ , testCaseSteps "testError" testError
]
-testBasicOperation :: Assertion
-testBasicOperation = do
+testRawOperation :: (String -> IO ()) -> Assertion
+testRawOperation step = do
+ step "test fs"
Right op <- newOp "fs" $ HashMap.fromList [("root", "/tmp/opendal-test")]
- writeOp op "key1" "value1" >>= (@?= Right ())
- writeOp op "key2" "value2" >>= (@?= Right ())
- readOp op "key1" >>= (@?= Right "value1")
- readOp op "key2" >>= (@?= Right "value2")
- isExistOp op "key1" >>= (@?= Right True)
- isExistOp op "key2" >>= (@?= Right True)
- createDirOp op "dir1/" >>= (@?= Right ())
- isExistOp op "dir1/" >>= (@?= Right True)
- copyOp op "key1" "key3" >>= (@?= Right ())
- isExistOp op "key3" >>= (@?= Right True)
- isExistOp op "key1" >>= (@?= Right True)
- renameOp op "key2" "key4" >>= (@?= Right ())
- isExistOp op "key4" >>= (@?= Right True)
- isExistOp op "key2" >>= (@?= Right False)
- deleteOp op "key1" >>= (@?= Right ())
- isExistOp op "key1" >>= (@?= Right False)
\ No newline at end of file
+ writeOpRaw op "key1" "value1" >>= (@?= Right ())
+ writeOpRaw op "key2" "value2" >>= (@?= Right ())
+ readOpRaw op "key1" >>= (@?= Right "value1")
+ readOpRaw op "key2" >>= (@?= Right "value2")
+ isExistOpRaw op "key1" >>= (@?= Right True)
+ isExistOpRaw op "key2" >>= (@?= Right True)
+ createDirOpRaw op "dir1/" >>= (@?= Right ())
+ isExistOpRaw op "dir1/" >>= (@?= Right True)
+ copyOpRaw op "key1" "key3" >>= (@?= Right ())
+ isExistOpRaw op "key3" >>= (@?= Right True)
+ isExistOpRaw op "key1" >>= (@?= Right True)
+ renameOpRaw op "key2" "key4" >>= (@?= Right ())
+ isExistOpRaw op "key4" >>= (@?= Right True)
+ isExistOpRaw op "key2" >>= (@?= Right False)
+ deleteOpRaw op "key1" >>= (@?= Right ())
+ isExistOpRaw op "key1" >>= (@?= Right False)
+ step "test memory"
+ Right op2 <- newOp "memory" HashMap.empty
+ writeOpRaw op2 "key1" "value1" >>= (@?= Right ())
+ writeOpRaw op2 "key2" "value2" >>= (@?= Right ())
+ readOpRaw op2 "key1" >>= (@?= Right "value1")
+ readOpRaw op2 "key2" >>= (@?= Right "value2")
+ isExistOpRaw op2 "key1" >>= (@?= Right True)
+ isExistOpRaw op2 "key2" >>= (@?= Right True)
+ createDirOpRaw op2 "dir1/" >>= (@?= Right ())
+ isExistOpRaw op2 "dir1/" >>= (@?= Right True)
+ deleteOpRaw op2 "key1" >>= (@?= Right ())
+ isExistOpRaw op2 "key1" >>= (@?= Right False)
+
+testMonad :: (String -> IO ()) -> Assertion
+testMonad step = do
+ step "test fs"
+ Right op <- newOp "fs" $ HashMap.fromList [("root", "/tmp/opendal-test2")]
Review Comment:
> So should we only add tests for `memory`, and need to remove `fs` test?
Yes.
> `Memory` doesn't support `copy` and `rename` so that it can't cover all basic operations.
Please create an issue for this, we can add them.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-opendal] silver-ymz commented on a diff in pull request #2482: feat(bindings/haskell): add `Monad` wrapper
Posted by "silver-ymz (via GitHub)" <gi...@apache.org>.
silver-ymz commented on code in PR #2482:
URL: https://github.com/apache/incubator-opendal/pull/2482#discussion_r1233200764
##########
bindings/haskell/test/BasicTest.hs:
##########
@@ -27,25 +28,59 @@ basicTests :: TestTree
basicTests =
testGroup
"Basic Tests"
- [ testCase "testBasicOperation" testBasicOperation
+ [ testCase "testBasicOperation" testRawOperation
+ , testCase "testMonad" testMonad
+ , testCase "testError" testError
]
-testBasicOperation :: Assertion
-testBasicOperation = do
+testRawOperation :: Assertion
+testRawOperation = do
Right op <- newOp "fs" $ HashMap.fromList [("root", "/tmp/opendal-test")]
- writeOp op "key1" "value1" >>= (@?= Right ())
- writeOp op "key2" "value2" >>= (@?= Right ())
- readOp op "key1" >>= (@?= Right "value1")
- readOp op "key2" >>= (@?= Right "value2")
- isExistOp op "key1" >>= (@?= Right True)
- isExistOp op "key2" >>= (@?= Right True)
- createDirOp op "dir1/" >>= (@?= Right ())
- isExistOp op "dir1/" >>= (@?= Right True)
- copyOp op "key1" "key3" >>= (@?= Right ())
- isExistOp op "key3" >>= (@?= Right True)
- isExistOp op "key1" >>= (@?= Right True)
- renameOp op "key2" "key4" >>= (@?= Right ())
- isExistOp op "key4" >>= (@?= Right True)
- isExistOp op "key2" >>= (@?= Right False)
- deleteOp op "key1" >>= (@?= Right ())
- isExistOp op "key1" >>= (@?= Right False)
\ No newline at end of file
+ writeOpRaw op "key1" "value1" >>= (@?= Right ())
+ writeOpRaw op "key2" "value2" >>= (@?= Right ())
+ readOpRaw op "key1" >>= (@?= Right "value1")
+ readOpRaw op "key2" >>= (@?= Right "value2")
+ isExistOpRaw op "key1" >>= (@?= Right True)
+ isExistOpRaw op "key2" >>= (@?= Right True)
+ createDirOpRaw op "dir1/" >>= (@?= Right ())
+ isExistOpRaw op "dir1/" >>= (@?= Right True)
+ copyOpRaw op "key1" "key3" >>= (@?= Right ())
+ isExistOpRaw op "key3" >>= (@?= Right True)
+ isExistOpRaw op "key1" >>= (@?= Right True)
+ renameOpRaw op "key2" "key4" >>= (@?= Right ())
+ isExistOpRaw op "key4" >>= (@?= Right True)
+ isExistOpRaw op "key2" >>= (@?= Right False)
+ deleteOpRaw op "key1" >>= (@?= Right ())
+ isExistOpRaw op "key1" >>= (@?= Right False)
+
+testMonad :: Assertion
+testMonad = do
+ Right op <- newOp "fs" $ HashMap.fromList [("root", "/tmp/opendal-test2")]
+ runOp op operation >>= (@?= Right ())
+ where
+ operation = do
+ writeOp "key1" "value1"
+ writeOp "key2" "value2"
+ readOp "key1" >>= liftIO . (@?= "value1")
+ readOp "key2" >>= liftIO . (@?= "value2")
+ isExistOp "key1" >>= liftIO . (@?= True)
+ isExistOp "key2" >>= liftIO . (@?= True)
+ createDirOp "dir1/"
+ isExistOp "dir1/" >>= liftIO . (@?= True)
+ copyOp "key1" "key3"
+ isExistOp "key3" >>= liftIO . (@?= True)
+ isExistOp "key1" >>= liftIO . (@?= True)
+ renameOp "key2" "key4"
+ isExistOp "key4" >>= liftIO . (@?= True)
+ isExistOp "key2" >>= liftIO . (@?= False)
+ deleteOp "key1"
+ isExistOp "key1" >>= liftIO . (@?= False)
+
+testError :: Assertion
+testError = do
+ Right op <- newOp "fs" $ HashMap.fromList [("root", "/tmp/opendal-test3")]
Review Comment:
updated in new commit
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-opendal] silver-ymz commented on a diff in pull request #2482: feat(bindings/haskell): add `Monad` wrapper
Posted by "silver-ymz (via GitHub)" <gi...@apache.org>.
silver-ymz commented on code in PR #2482:
URL: https://github.com/apache/incubator-opendal/pull/2482#discussion_r1233201086
##########
bindings/haskell/test/BasicTest.hs:
##########
@@ -27,25 +28,76 @@ basicTests :: TestTree
basicTests =
testGroup
"Basic Tests"
- [ testCase "testBasicOperation" testBasicOperation
+ [ testCaseSteps "testBasicOperation" testRawOperation
+ , testCaseSteps "testMonad" testMonad
+ , testCaseSteps "testError" testError
]
-testBasicOperation :: Assertion
-testBasicOperation = do
+testRawOperation :: (String -> IO ()) -> Assertion
+testRawOperation step = do
+ step "test fs"
Right op <- newOp "fs" $ HashMap.fromList [("root", "/tmp/opendal-test")]
- writeOp op "key1" "value1" >>= (@?= Right ())
- writeOp op "key2" "value2" >>= (@?= Right ())
- readOp op "key1" >>= (@?= Right "value1")
- readOp op "key2" >>= (@?= Right "value2")
- isExistOp op "key1" >>= (@?= Right True)
- isExistOp op "key2" >>= (@?= Right True)
- createDirOp op "dir1/" >>= (@?= Right ())
- isExistOp op "dir1/" >>= (@?= Right True)
- copyOp op "key1" "key3" >>= (@?= Right ())
- isExistOp op "key3" >>= (@?= Right True)
- isExistOp op "key1" >>= (@?= Right True)
- renameOp op "key2" "key4" >>= (@?= Right ())
- isExistOp op "key4" >>= (@?= Right True)
- isExistOp op "key2" >>= (@?= Right False)
- deleteOp op "key1" >>= (@?= Right ())
- isExistOp op "key1" >>= (@?= Right False)
\ No newline at end of file
+ writeOpRaw op "key1" "value1" >>= (@?= Right ())
+ writeOpRaw op "key2" "value2" >>= (@?= Right ())
+ readOpRaw op "key1" >>= (@?= Right "value1")
+ readOpRaw op "key2" >>= (@?= Right "value2")
+ isExistOpRaw op "key1" >>= (@?= Right True)
+ isExistOpRaw op "key2" >>= (@?= Right True)
+ createDirOpRaw op "dir1/" >>= (@?= Right ())
+ isExistOpRaw op "dir1/" >>= (@?= Right True)
+ copyOpRaw op "key1" "key3" >>= (@?= Right ())
+ isExistOpRaw op "key3" >>= (@?= Right True)
+ isExistOpRaw op "key1" >>= (@?= Right True)
+ renameOpRaw op "key2" "key4" >>= (@?= Right ())
+ isExistOpRaw op "key4" >>= (@?= Right True)
+ isExistOpRaw op "key2" >>= (@?= Right False)
+ deleteOpRaw op "key1" >>= (@?= Right ())
+ isExistOpRaw op "key1" >>= (@?= Right False)
+ step "test memory"
+ Right op2 <- newOp "memory" HashMap.empty
+ writeOpRaw op2 "key1" "value1" >>= (@?= Right ())
+ writeOpRaw op2 "key2" "value2" >>= (@?= Right ())
+ readOpRaw op2 "key1" >>= (@?= Right "value1")
+ readOpRaw op2 "key2" >>= (@?= Right "value2")
+ isExistOpRaw op2 "key1" >>= (@?= Right True)
+ isExistOpRaw op2 "key2" >>= (@?= Right True)
+ createDirOpRaw op2 "dir1/" >>= (@?= Right ())
+ isExistOpRaw op2 "dir1/" >>= (@?= Right True)
+ deleteOpRaw op2 "key1" >>= (@?= Right ())
+ isExistOpRaw op2 "key1" >>= (@?= Right False)
+
+testMonad :: (String -> IO ()) -> Assertion
+testMonad step = do
+ step "test fs"
+ Right op <- newOp "fs" $ HashMap.fromList [("root", "/tmp/opendal-test2")]
Review Comment:
This has already added tests for memory
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org