1import ProjectM36.Client.Simple
4import ProjectM36.Relation
5import qualified ProjectM36.Client as C
8import ProjectM36.TupleSet
9import ProjectM36.Attribute
10import qualified Data.Vector as V
14 tcounts <- runTestTT testList
15 if errors tcounts + failures tcounts > 0 then exitFailure else exitSuccess
18testList = TestList [testSimpleCommitSuccess, testSimpleCommitFailure]
20assertEither :: (Show a) => IO (Either a b) -> IO b
24 Left err -> assertFailure (show err) >> undefined
27testSimpleCommitSuccess :: Test
28testSimpleCommitSuccess = TestCase $
29 withSystemTempDirectory "m36tempdb" $ \tempdir -> do
30 let connInfo = InProcessConnectionInfo (MinimalPersistence (tempdir </> "db")) emptyNotificationCallback []
31 relExpr = Union (RelationVariable "x" ()) (RelationVariable "y" ())
33 dbconn <- assertEither (simpleConnectProjectM36 connInfo)
34 Right rel <- withTransaction dbconn $ do
36 execute (Assign "x" (ExistingRelation relationTrue))
37 execute (Assign "y" (ExistingRelation relationFalse))
40 assertEqual "true/false simple" relationTrue rel
41 -- re-open with standard API and validate that the relvars are available
42 conn <- assertEither $ C.connectProjectM36 connInfo
44 sess <- assertEither $ C.createSessionAtHead conn "master"
45 eRes <- C.executeRelationalExpr sess conn relExpr
46 assertEqual "x and y" (Right relationTrue) eRes
48testSimpleCommitFailure :: Test
49testSimpleCommitFailure = TestCase $ do
50 let failAttrs = attributesFromList [Attribute "fail" IntAtomType]
51 err <- withSystemTempDirectory "m36tempdb" $ \tempdir -> do
52 let connInfo = InProcessConnectionInfo (MinimalPersistence (tempdir </> "db")) emptyNotificationCallback []
53 dbconn <- assertEither (simpleConnectProjectM36 connInfo)
54 withTransaction dbconn $ do
55 execute $ Assign "x" (ExistingRelation relationTrue)
57 execute $ Assign "x" (MakeStaticRelation failAttrs emptyTupleSet)
58 let expectedErr = Left (RelError (RelationTypeMismatchError V.empty failAttrs))
59 assertEqual "dbc error" expectedErr err
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list