From 7120b95731c6d71a61302cbf5effa7ca75e5f348 Mon Sep 17 00:00:00 2001 From: Shi Han NG Date: Thu, 16 Jul 2020 08:33:00 +0900 Subject: [PATCH] add TestStripIndent --- command/help_test.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 command/help_test.go diff --git a/command/help_test.go b/command/help_test.go new file mode 100644 index 000000000..e5fbc8489 --- /dev/null +++ b/command/help_test.go @@ -0,0 +1,27 @@ +package command + +import ( + "testing" +) + +func TestStripIndent(t *testing.T) { + type c struct { + input string + expected string + } + + cases := []c{ + { + input: " --help Show help for command\n --version Show gh version", + expected: "--help Show help for command\n--version Show gh version\n", + }, + { + input: " --help Show help for command\n -R, --repo OWNER/REPO Select another repository using the OWNER/REPO format", + expected: " --help Show help for command\n-R, --repo OWNER/REPO Select another repository using the OWNER/REPO format", + }, + } + + for _, kase := range cases { + eq(t, stripIndent(kase.input), kase.expected) + } +}