0001-contrib-oid2name-add-TAP-tests-for-object-listing.patch
application/octet-stream
Filename: 0001-contrib-oid2name-add-TAP-tests-for-object-listing.patch
Type: application/octet-stream
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch 0001
Subject: contrib/oid2name: add TAP tests for object listing
| File | + | − |
|---|---|---|
| contrib/oid2name/t/002_actions.pl | 80 | 0 |
From a862a65c464391339a45352a71ec0a95971f9b77 Mon Sep 17 00:00:00 2001
From: Sergii Glushchenko <gsserge@gmail.com>
Date: Sun, 10 May 2026 21:34:44 +0200
Subject: [PATCH] contrib/oid2name: add TAP tests for object listing
---
contrib/oid2name/t/002_actions.pl | 80 +++++++++++++++++++++++++++++++
1 file changed, 80 insertions(+)
create mode 100644 contrib/oid2name/t/002_actions.pl
diff --git a/contrib/oid2name/t/002_actions.pl b/contrib/oid2name/t/002_actions.pl
new file mode 100644
index 00000000000..343be26629f
--- /dev/null
+++ b/contrib/oid2name/t/002_actions.pl
@@ -0,0 +1,80 @@
+
+# Copyright (c) 2026, PostgreSQL Global Development Group
+
+# Do basic object listsing supported by oid2name using
+# an initialized cluster.
+
+use strict;
+use warnings FATAL => 'all';
+use PostgreSQL::Test::Cluster;
+use PostgreSQL::Test::Utils;
+
+use Test::More;
+
+sub get_oid
+{
+ my $node = shift;
+ my $name = shift;
+ return
+ int($node->safe_psql('postgres', "SELECT to_regclass('$name')::oid"));
+}
+
+my $node = PostgreSQL::Test::Cluster->new('mynode');
+$node->init;
+$node->start;
+
+# Check default databases, tablespaces and system objects.
+$node->command_like(['oid2name'], qr/postgres\s+pg_default\b/,
+ "successfuly shows default databases with no arguments");
+
+$node->command_like([ 'oid2name', '--tablespaces' ],
+ qr/pg_default\b/, "successfuly shows default tablespaces");
+
+$node->command_like([ 'oid2name', '--quiet', '--dbname' => 'postgres' ],
+ qr/^$/, "succeeds in quiet mode");
+
+my $pg_class_oid = get_oid($node, 'pg_class');
+$node->command_like(
+ [ 'oid2name', '--system-objects', '--dbname' => 'postgres' ],
+ qr/${pg_class_oid}\s+pg_class\b/,
+ "successfuly shows a system object");
+
+# Create a test table with index and sequence, and then list the objects.
+my $table = 't1';
+my $index = "${table}_pkey";
+my $seq = "${table}_id_seq";
+
+$node->safe_psql('postgres', "CREATE TABLE $table(id SERIAL PRIMARY KEY)");
+
+my $table_oid = get_oid($node, $table);
+my $index_oid = get_oid($node, $index);
+my $seq_oid = get_oid($node, $seq);
+
+$node->command_like(
+ [ 'oid2name', '--dbname' => 'postgres', '--table' => $table ],
+ qr/${table_oid}\s+${table}\b/, "successfuly shows table $table");
+
+$node->command_like([ 'oid2name', '--dbname' => 'postgres' ],
+ qr/${table_oid}\s+${table}\b/,
+ "successfuly shows table $table in the database output");
+
+$node->command_like(
+ [ 'oid2name', '--dbname' => 'postgres', '--oid' => $table_oid ],
+ qr/${table_oid}\s+${table}\b/,
+ "successfuly shows table $table for oid $table_oid");
+
+$node->command_like(
+ [ 'oid2name', '--dbname' => 'postgres', '--filenode' => $table_oid ],
+ qr/${table_oid}\s+${table}\b/,
+ "successfuly shows table $table for filenode $table_oid");
+
+$node->command_like(
+ [ 'oid2name', '--dbname' => 'postgres', '--indexes' ],
+ qr/${index_oid}\s+${index}\b/,
+ "successfuly shows index $index in the output with indexes");
+
+$node->command_like([ 'oid2name', '--dbname' => 'postgres', '--indexes' ],
+ qr/${seq_oid}\s+${seq}\b/,
+ "successfuly shows sequence $seq in the output with indexes");
+
+done_testing();
--
2.54.0