From 87dec759a665729971e162e17600207b3e2f5a22 Mon Sep 17 00:00:00 2001
From: Nitin Motiani <nitinmotiani@google.com>
Date: Sat, 15 Feb 2025 04:29:17 +0000
Subject: [PATCH v5 3/5] Add basic tests for pipe-command

* This currently only adds a few basic tests for pg_dump with --pipe-command.
* These tests include the invalid usages of --pipe-command with other flags.
* We are still working on adding other tests in pg_dump.pl. But
  we ran into some issues which might be related to setup.
---
 src/bin/pg_dump/t/001_basic.pl | 36 ++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/src/bin/pg_dump/t/001_basic.pl b/src/bin/pg_dump/t/001_basic.pl
index 84ca25e17d6..3badd335f8c 100644
--- a/src/bin/pg_dump/t/001_basic.pl
+++ b/src/bin/pg_dump/t/001_basic.pl
@@ -74,6 +74,42 @@ command_fails_like(
 	'pg_dump: options --statistics-only and --no-statistics cannot be used together'
 );
 
+command_fails_like(
+	[ 'pg_dump', '-Fd', '--pipe-command="cat"', '-f', 'testdir', 'test'],
+	qr/\Qpg_dump: hint: Only one of [--file, --pipe-command] allowed\E/,
+	'pg_dump: hint: Only one of [--file, --pipe-command] allowed'
+);
+
+command_fails_like(
+	[ 'pg_dump', '-Fd', '--pipe-command="cat"', '-Z', 'gzip', 'test'],
+	qr/\Qpg_dump: hint: Option --pipe-command is not supported with any compression type\E/,
+	'pg_dump: hint: Option --pipe-command is not supported with any compression type'
+);
+
+command_fails_like(
+	[ 'pg_dump', '-Fd', '--pipe-command="cat"', '--compress=lz4', 'test'],
+	qr/\Qpg_dump: hint: Option --pipe-command is not supported with any compression type\E/,
+	'pg_dump: hint: Option --pipe-command is not supported with any compression type'
+);
+
+command_fails_like(
+	[ 'pg_dump', '-Fd', '--pipe-command="cat"', '-Z', '1', 'test'],
+	qr/\Qpg_dump: hint: Option --pipe-command is not supported with any compression type\E/,
+	'pg_dump: hint: Option --pipe-command is not supported with any compression type'
+);
+
+command_fails_like(
+	[ 'pg_dump', '-Fc', '--pipe-command="cat"', 'test'],
+	qr/\Qpg_dump: hint: Option --pipe-command is only supported with directory format.\E/,
+	'pg_dump: hint: Option --pipe-command is only supported with directory format.'
+);
+
+command_fails_like(
+	[ 'pg_dump', '--format=tar', '--pipe-command="cat"', 'test'],
+	qr/\Qpg_dump: hint: Option --pipe-command is only supported with directory format.\E/,
+	'pg_dump: hint: Option --pipe-command is only supported with directory format.'
+);
+
 command_fails_like(
 	[ 'pg_dump', '-j2', '--include-foreign-data=xxx' ],
 	qr/\Qpg_dump: error: option --include-foreign-data is not supported with parallel backup\E/,
-- 
2.49.0.1266.g31b7d2e469-goog

