1import ProjectM36.Client.Simple
4import ProjectM36.Relation
5import qualified ProjectM36.Client as C
6import ProjectM36.DateExamples
7import ProjectM36.DatabaseContext
10import ProjectM36.TupleSet
11import ProjectM36.Attribute
12import qualified Data.Vector as V
13import qualified Data.Map as M
17 tcounts <- runTestTT testList
18 if errors tcounts + failures tcounts > 0 then exitFailure else exitSuccess
21testList = TestList [testSimpleCommitSuccess, testSimpleCommitFailure, testSimpleUpdate]
23assertEither :: (Show a) => IO (Either a b) -> IO b
27 Left err -> assertFailure (show err) >> undefined
30testSimpleCommitSuccess :: Test
31testSimpleCommitSuccess = TestCase $
32 withSystemTempDirectory "m36tempdb" $ \tempdir -> do
33 let connInfo = InProcessConnectionInfo (MinimalPersistence (tempdir </> "db")) emptyNotificationCallback []
34 relExpr = Union (RelationVariable "x" ()) (RelationVariable "y" ())
36 dbconn <- assertEither (simpleConnectProjectM36 connInfo)
37 Right rel <- withTransaction dbconn $ do
39 execute (Assign "x" (ExistingRelation relationTrue))
40 execute (Assign "y" (ExistingRelation relationFalse))
43 assertEqual "true/false simple" relationTrue rel
44 -- re-open with standard API and validate that the relvars are available
45 conn <- assertEither $ C.connectProjectM36 connInfo
47 sess <- assertEither $ C.createSessionAtHead conn "master"
48 eRes <- C.executeRelationalExpr sess conn relExpr
49 assertEqual "x and y" (Right relationTrue) eRes
52testSimpleCommitFailure :: Test
53testSimpleCommitFailure = TestCase $ do
54 let failAttrs = attributesFromList [Attribute "fail" IntAtomType]
55 err <- withSystemTempDirectory "m36tempdb" $ \tempdir -> do
56 let connInfo = InProcessConnectionInfo (MinimalPersistence (tempdir </> "db")) emptyNotificationCallback []
57 dbconn <- assertEither (simpleConnectProjectM36 connInfo)
58 withTransaction dbconn $ do
59 execute $ Assign "x" (ExistingRelation relationTrue)
61 execute $ Assign "x" (MakeStaticRelation failAttrs emptyTupleSet)
62 let expectedErr = Left (RelError (RelationTypeMismatchError V.empty failAttrs))
63 assertEqual "dbc error" expectedErr err
65-- #176 default merge couldn't handle Update
66testSimpleUpdate :: Test
67testSimpleUpdate = TestCase $ do
68 let connInfo = InProcessConnectionInfo NoPersistence emptyNotificationCallback []
69 dbconn <- assertEither (simpleConnectProjectM36 connInfo)
70 assertEither $ withTransaction dbconn $
71 execute $ databaseContextAsDatabaseContextExpr dateExamples
72 assertEither $ withTransaction dbconn $
73 execute $ Update "s" (M.singleton "sname" (C.NakedAtomExpr (C.TextAtom "Blakey"))) (C.AttributeEqualityPredicate "sname" (C.NakedAtomExpr (C.TextAtom "Blake")))
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