Fix tests

This commit is contained in:
Chris Penner 2022-09-12 16:18:17 -06:00
parent 993b4de72b
commit d8ebfc7d57
3 changed files with 11 additions and 11 deletions

View File

@ -290,7 +290,7 @@ createSchema = do
where
insertSchemaVersionSql =
[here|
INSERT INTO schema_version (version) VALUES (?);
INSERT INTO schema_version (version) VALUES (?)
|]
addTempEntityTables :: Transaction ()

View File

@ -29,7 +29,7 @@ test =
[ scope "a v2 codebase should be opened" do
tmp <- io (Temp.getCanonicalTemporaryDirectory >>= flip Temp.createTempDirectory "ucm-test")
cbInit <- io initMockWithCodebase
r <- io $ CI.withOpenOrCreateCodebase cbInit "ucm-test" (Home tmp) \case
r <- io $ CI.withOpenOrCreateCodebase cbInit "ucm-test" (Home tmp) CI.DontMigrate \case
(CI.OpenedCodebase, _, _) -> pure True
_ -> pure False
case r of
@ -38,7 +38,7 @@ test =
scope "a v2 codebase should be created when one does not exist" do
tmp <- io (Temp.getCanonicalTemporaryDirectory >>= flip Temp.createTempDirectory "ucm-test")
cbInit <- io initMockWithoutCodebase
r <- io $ CI.withOpenOrCreateCodebase cbInit "ucm-test" (Home tmp) \case
r <- io $ CI.withOpenOrCreateCodebase cbInit "ucm-test" (Home tmp) CI.DontMigrate \case
(CI.CreatedCodebase, _, _) -> pure True
_ -> pure False
case r of
@ -51,7 +51,7 @@ test =
tmp <- io (Temp.getCanonicalTemporaryDirectory >>= flip Temp.createTempDirectory "ucm-test")
cbInit <- io initMockWithCodebase
res <- io $
CI.withOpenOrCreateCodebase cbInit "ucm-test" (Specified (DontCreateWhenMissing tmp)) $ \case
CI.withOpenOrCreateCodebase cbInit "ucm-test" (Specified (DontCreateWhenMissing tmp)) CI.DontMigrate $ \case
(CI.OpenedCodebase, _, _) -> pure True
_ -> pure False
case res of
@ -61,7 +61,7 @@ test =
tmp <- io (Temp.getCanonicalTemporaryDirectory >>= flip Temp.createTempDirectory "ucm-test")
cbInit <- io initMockWithoutCodebase
res <- io $
CI.withOpenOrCreateCodebase cbInit "ucm-test" (Specified (DontCreateWhenMissing tmp)) $ \case
CI.withOpenOrCreateCodebase cbInit "ucm-test" (Specified (DontCreateWhenMissing tmp)) CI.DontMigrate $ \case
_ -> pure False
case res of
Left (_, CI.InitErrorOpen OpenCodebaseDoesntExist) -> expect True
@ -72,7 +72,7 @@ test =
[ scope "a v2 codebase should be created when one does not exist at the Specified dir" do
tmp <- io (Temp.getCanonicalTemporaryDirectory >>= flip Temp.createTempDirectory "ucm-test")
cbInit <- io initMockWithoutCodebase
res <- io $ CI.withOpenOrCreateCodebase cbInit "ucm-test" (Specified (CreateWhenMissing tmp)) \case
res <- io $ CI.withOpenOrCreateCodebase cbInit "ucm-test" (Specified (CreateWhenMissing tmp)) CI.DontMigrate \case
(CI.CreatedCodebase, _, _) -> pure True
_ -> pure False
case res of
@ -81,7 +81,7 @@ test =
scope "a v2 codebase should be opened when one exists" do
tmp <- io (Temp.getCanonicalTemporaryDirectory >>= flip Temp.createTempDirectory "ucm-test")
cbInit <- io initMockWithCodebase
res <- io $ CI.withOpenOrCreateCodebase cbInit "ucm-test" (Specified (CreateWhenMissing tmp)) \case
res <- io $ CI.withOpenOrCreateCodebase cbInit "ucm-test" (Specified (CreateWhenMissing tmp)) CI.DontMigrate \case
(CI.OpenedCodebase, _, _) -> pure True
_ -> pure False
case res of
@ -98,7 +98,7 @@ initMockWithCodebase = do
pure $
Init
{ -- withOpenCodebase :: forall r. DebugName -> CodebasePath -> (Codebase m v a -> m r) -> m (Either Pretty r),
withOpenCodebase = \_ _ action -> Right <$> action codebase,
withOpenCodebase = \_ _ _ action -> Right <$> action codebase,
-- withCreatedCodebase :: forall r. DebugName -> CodebasePath -> (Codebase m v a -> m r) -> m (Either CreateCodebaseError r),
withCreatedCodebase = \_ _ action -> Right <$> action codebase,
-- CodebasePath -> CodebasePath
@ -110,7 +110,7 @@ initMockWithoutCodebase = do
let codebase = error "did we /actually/ need a Codebase?"
pure $
Init
{ withOpenCodebase = \_ _ _ -> pure (Left OpenCodebaseDoesntExist),
{ withOpenCodebase = \_ _ _ _ -> pure (Left OpenCodebaseDoesntExist),
-- withCreatedCodebase :: forall r. DebugName -> CodebasePath -> (Codebase m v a -> m r) -> m (Either CreateCodebaseError r),
withCreatedCodebase = \_ _ action -> Right <$> action codebase,
-- CodebasePath -> CodebasePath

View File

@ -66,7 +66,7 @@ runTranscript (Codebase codebasePath fmt) transcript = do
let err e = fail $ "Parse error: \n" <> show e
cbInit = case fmt of CodebaseFormat2 -> SC.init
TR.withTranscriptRunner "Unison.Test.Ucm.runTranscript Invalid Version String" configFile $ \runner -> do
result <- Codebase.Init.withOpenCodebase cbInit "transcript" codebasePath \codebase -> do
result <- Codebase.Init.withOpenCodebase cbInit "transcript" codebasePath SC.DontMigrate \codebase -> do
Codebase.installUcmDependencies codebase
let transcriptSrc = Text.pack . stripMargin $ unTranscript transcript
output <- either err Text.unpack <$> runner "transcript" transcriptSrc (codebasePath, codebase)
@ -81,7 +81,7 @@ runTranscript (Codebase codebasePath fmt) transcript = do
lowLevel :: Codebase -> (Codebase.Codebase IO Symbol Ann -> IO a) -> IO a
lowLevel (Codebase root fmt) action = do
let cbInit = case fmt of CodebaseFormat2 -> SC.init
result <- Codebase.Init.withOpenCodebase cbInit "lowLevel" root action
result <- Codebase.Init.withOpenCodebase cbInit "lowLevel" root SC.DontMigrate action
case result of
Left e -> PT.putPrettyLn (P.shown e) *> pure (error "This really should have loaded")
Right a -> pure a