From aa82832f7ba0a6ca7017f019be17810579f9a688 Mon Sep 17 00:00:00 2001 From: Ash McKenzie Date: Fri, 18 Oct 2019 14:30:51 +1100 Subject: More consistent console messages (Ruby) --- spec/gitlab_shell_custom_git_receive_pack_spec.rb | 26 ++++++++++++++++------- spec/gitlab_shell_lfs_authentication_spec.rb | 3 ++- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/spec/gitlab_shell_custom_git_receive_pack_spec.rb b/spec/gitlab_shell_custom_git_receive_pack_spec.rb index 0a57903..4b0fec4 100644 --- a/spec/gitlab_shell_custom_git_receive_pack_spec.rb +++ b/spec/gitlab_shell_custom_git_receive_pack_spec.rb @@ -8,6 +8,7 @@ describe 'Custom bin/gitlab-shell git-receive-pack' do include_context 'gitlab shell' let(:env) { {'SSH_CONNECTION' => 'fake', 'SSH_ORIGINAL_COMMAND' => 'git-receive-pack group/repo' } } + let(:divider) { "remote: ========================================================================\n" } before(:context) do write_config("gitlab_url" => "http+unix://#{CGI.escape(tmp_socket_path)}") @@ -65,21 +66,24 @@ describe 'Custom bin/gitlab-shell git-receive-pack' do end describe 'dialog for performing a custom action' do - let(:inaccessible_error) { "Internal API error (403)\n" } - context 'when API calls perform successfully' do + let(:remote_blank_line) { "remote: \n" } def verify_successful_call!(cmd) Open3.popen3(env, cmd) do |stdin, stdout, stderr| - expect(stderr.gets).to eq("> GitLab: console\n") - expect(stderr.gets).to eq("> GitLab: message\n") + expect(stderr.gets).to eq(remote_blank_line) + expect(stderr.gets).to eq("remote: console\n") + expect(stderr.gets).to eq("remote: message\n") + expect(stderr.gets).to eq(remote_blank_line) - expect(stderr.gets).to eq("> GitLab: info_message\n") - expect(stderr.gets).to eq("> GitLab: another_message\n") - expect(stdout.gets(6)).to eq("custom") + expect(stderr.gets).to eq(remote_blank_line) + expect(stderr.gets).to eq("remote: info_message\n") + expect(stderr.gets).to eq("remote: another_message\n") + expect(stderr.gets).to eq(remote_blank_line) stdin.puts("input") stdin.close + expect(stdout.gets(6)).to eq("custom") expect(stdout.flush.read).to eq("input\n") end end @@ -106,7 +110,13 @@ describe 'Custom bin/gitlab-shell git-receive-pack' do it 'custom action is not performed' do Open3.popen2e(env, cmd) do |stdin, stdout| - expect(stdout.gets).to eq(inaccessible_error) + expect(stdout.gets).to eq("remote: \n") + expect(stdout.gets).to eq(divider) + expect(stdout.gets).to eq("remote: \n") + expect(stdout.gets).to eq("remote: Internal API error (403)\n") + expect(stdout.gets).to eq("remote: \n") + expect(stdout.gets).to eq(divider) + expect(stdout.gets).to eq("remote: \n") end end end diff --git a/spec/gitlab_shell_lfs_authentication_spec.rb b/spec/gitlab_shell_lfs_authentication_spec.rb index d27f50a..437005c 100644 --- a/spec/gitlab_shell_lfs_authentication_spec.rb +++ b/spec/gitlab_shell_lfs_authentication_spec.rb @@ -117,9 +117,10 @@ describe 'bin/gitlab-shell git-lfs-authentication' do let(:env) { {'SSH_CONNECTION' => 'fake', 'SSH_ORIGINAL_COMMAND' => 'git-lfs-authenticate project/repo unknown' } } it 'the command is disallowed' do + divider = "remote: \nremote: ========================================================================\nremote: \n" _, stderr, status = Open3.capture3(env, cmd) - expect(stderr).to eq("> GitLab: Disallowed command\n") + expect(stderr).to eq("#{divider}remote: Disallowed command\n#{divider}") expect(status).not_to be_success end end -- cgit v1.2.1