module Integration.Sharing.SessionSpec (spec) whereimport Data.Eitherimport Hasql.Connection qualified as Connectionimport Helpers.Dsls.Execution qualified as Executionimport Helpers.Scripts qualified as Scriptsimport Helpers.Statements qualified as Statementsimport Preludeimport Test.Hspecspec :: SpecWith Scripts.ScopeParamsspec = do -- Note the guarantee this does not extend to: an interruption takes the -- connection with it, and server-side session state goes with the -- connection. See "Integration.Sharing.Connection.Use.InterruptionSpec". it "Does not lose the server-side session state between uses" \config -> do Scripts.onPreparableConnection config \connection -> do varname <- Execution.generateVarname result <- Connection.use connection do Execution.sessionByParams (Statements.SetConfig varname "1" False) result `shouldSatisfy` isRight result <- Connection.use connection do Execution.sessionByParams (Statements.CurrentSetting varname True) result `shouldBe` Right (Just "1")