-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: function to mock the time inside a transaction
- Loading branch information
Showing
6 changed files
with
34 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
-- Deploy mocks:set_mocked_time_in_transaction to pg | ||
-- requires: mock_now_method | ||
|
||
BEGIN; | ||
|
||
create or replace function mocks.set_mocked_time_in_transaction(mocked_timestamp timestamptz) | ||
returns void as | ||
$function$ | ||
|
||
set search_path=mocks,"$user",public; | ||
set_config('mocks.mocked_timestamp', mocked_timestamp, true); | ||
|
||
$function$ language plpgsql volatile; | ||
|
||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- Revert mocks:set_mocked_time_in_transaction from pg | ||
|
||
BEGIN; | ||
|
||
drop function mocks.set_mocked_time_in_transaction; | ||
|
||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- Verify mocks:set_mocked_time_in_transaction on pg | ||
|
||
BEGIN; | ||
|
||
select pg_get_functiondef('mocks.set_mocked_time_in_transaction(timestamptz)'::regprocedure); | ||
|
||
ROLLBACK; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.