1import ProjectM36.Client.Simple
4import ProjectM36.Relation
5import qualified ProjectM36.Client as C
8import ProjectM36.TupleSet
9import ProjectM36.Attribute
10import ProjectM36.Error
11import qualified Data.Vector as V
15 tcounts <- runTestTT testList
16 if errors tcounts + failures tcounts > 0 then exitFailure else exitSuccess
19testList = TestList [testSimpleCommitSuccess, testSimpleCommitFailure]
21assertEither :: (Show a) => IO (Either a b) -> IO b
25 Left err -> assertFailure (show err) >> undefined
28testSimpleCommitSuccess :: Test
29testSimpleCommitSuccess = TestCase $
30 withSystemTempDirectory "m36tempdb" $ \tempdir -> do
31 let connInfo = InProcessConnectionInfo (MinimalPersistence (tempdir </> "db")) emptyNotificationCallback []
32 relExpr = Union (RelationVariable "x" ()) (RelationVariable "y" ())
34 dbconn <- assertEither (simpleConnectProjectM36 connInfo)
35 Right rel <- withTransaction dbconn $ do
37 execute (Assign "x" (ExistingRelation relationTrue))
38 execute (Assign "y" (ExistingRelation relationFalse))
41 assertEqual "true/false simple" relationTrue rel
42 -- re-open with standard API and validate that the relvars are available
43 conn <- assertEither $ C.connectProjectM36 connInfo
45 sess <- assertEither $ C.createSessionAtHead conn "master"
46 eRes <- C.executeRelationalExpr sess conn relExpr
47 assertEqual "x and y" (Right relationTrue) eRes
49testSimpleCommitFailure :: Test
50testSimpleCommitFailure = TestCase $ do
51 let failAttrs = attributesFromList [Attribute "fail" IntAtomType]
52 err <- withSystemTempDirectory "m36tempdb" $ \tempdir -> do
53 let connInfo = InProcessConnectionInfo (MinimalPersistence (tempdir </> "db")) emptyNotificationCallback []
54 dbconn <- assertEither (simpleConnectProjectM36 connInfo)
55 withTransaction dbconn $ do
56 execute $ Assign "x" (ExistingRelation relationTrue)
58 execute $ Assign "x" (MakeStaticRelation failAttrs emptyTupleSet)
59 let expectedErr = Left (RelError (RelVarAssignmentTypeMismatchError V.empty failAttrs))
60 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