From eac23ebbacc00dedc7176c269c46dd0a74ef6039 Mon Sep 17 00:00:00 2001
From: Lee Dong Wook <sh95119@gmail.com>
Date: Mon, 8 Aug 2022 12:09:27 +0900
Subject: [PATCH] old_snapshot: add test for coverage

---
 contrib/old_snapshot/.gitignore                | 4 ++++
 contrib/old_snapshot/Makefile                  | 3 +++
 contrib/old_snapshot/expected/old_snapshot.out | 6 ++++++
 contrib/old_snapshot/old_snapshot.conf         | 1 +
 contrib/old_snapshot/sql/old_snapshot.sql      | 4 ++++
 5 files changed, 18 insertions(+)
 create mode 100644 contrib/old_snapshot/.gitignore
 create mode 100644 contrib/old_snapshot/expected/old_snapshot.out
 create mode 100644 contrib/old_snapshot/old_snapshot.conf
 create mode 100644 contrib/old_snapshot/sql/old_snapshot.sql

diff --git a/contrib/old_snapshot/.gitignore b/contrib/old_snapshot/.gitignore
new file mode 100644
index 000000000000..5dcb3ff97235
--- /dev/null
+++ b/contrib/old_snapshot/.gitignore
@@ -0,0 +1,4 @@
+# Generated subdirectories
+/log/
+/results/
+/tmp_check/
diff --git a/contrib/old_snapshot/Makefile b/contrib/old_snapshot/Makefile
index adb557532fc1..6265c6df0b7f 100644
--- a/contrib/old_snapshot/Makefile
+++ b/contrib/old_snapshot/Makefile
@@ -9,6 +9,9 @@ EXTENSION = old_snapshot
 DATA = old_snapshot--1.0.sql
 PGFILEDESC = "old_snapshot - utilities in support of old_snapshot_threshold"
 
+REGRESS = old_snapshot
+REGRESS_OPTS = --temp-config $(top_srcdir)/contrib/old_snapshot/old_snapshot.conf
+
 ifdef USE_PGXS
 PG_CONFIG = pg_config
 PGXS := $(shell $(PG_CONFIG) --pgxs)
diff --git a/contrib/old_snapshot/expected/old_snapshot.out b/contrib/old_snapshot/expected/old_snapshot.out
new file mode 100644
index 000000000000..a1341b5046f1
--- /dev/null
+++ b/contrib/old_snapshot/expected/old_snapshot.out
@@ -0,0 +1,6 @@
+CREATE EXTENSION old_snapshot;
+SELECT * FROM pg_old_snapshot_time_mapping() LIMIT 0;
+ array_offset | end_timestamp | newest_xmin 
+--------------+---------------+-------------
+(0 rows)
+
diff --git a/contrib/old_snapshot/old_snapshot.conf b/contrib/old_snapshot/old_snapshot.conf
new file mode 100644
index 000000000000..d847bb42da16
--- /dev/null
+++ b/contrib/old_snapshot/old_snapshot.conf
@@ -0,0 +1 @@
+old_snapshot_threshold = 1min
diff --git a/contrib/old_snapshot/sql/old_snapshot.sql b/contrib/old_snapshot/sql/old_snapshot.sql
new file mode 100644
index 000000000000..f7056def840d
--- /dev/null
+++ b/contrib/old_snapshot/sql/old_snapshot.sql
@@ -0,0 +1,4 @@
+CREATE EXTENSION old_snapshot;
+
+SELECT * FROM pg_old_snapshot_time_mapping() LIMIT 0;
+
