diff options
author | charlieablett <cablett@gitlab.com> | 2019-06-21 16:20:00 +0200 |
---|---|---|
committer | charlieablett <cablett@gitlab.com> | 2019-07-03 22:53:13 +1200 |
commit | f4890d90782ad42a802b89c2a17c83bf9fb9d123 (patch) | |
tree | 233421eff8ec110cc16b1dcb9b50bedccb044e76 /spec/graphql/types | |
parent | c99c30fdd6f3adf4fb29aad4b10e265be69d2d67 (diff) | |
download | gitlab-ce-f4890d90782ad42a802b89c2a17c83bf9fb9d123.tar.gz |
Alert if `calls_gitaly` declaration missing
- Move `calls_gitaly_check` to public
- Add instrumentation for flagging missing CallsGitaly declarations
- Wrap resolver proc in before-and-after Gitaly counts to get the net
Gitaly call count for the resolver.
Diffstat (limited to 'spec/graphql/types')
-rw-r--r-- | spec/graphql/types/base_field_spec.rb | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/spec/graphql/types/base_field_spec.rb b/spec/graphql/types/base_field_spec.rb index d7360872508..0be83ea60c4 100644 --- a/spec/graphql/types/base_field_spec.rb +++ b/spec/graphql/types/base_field_spec.rb @@ -106,26 +106,18 @@ describe Types::BaseField do let(:no_gitaly_field) { described_class.new(name: 'test', type: GraphQL::STRING_TYPE, null: true, calls_gitaly: false) } context 'if there are no Gitaly calls' do - before do - allow(Gitlab::GitalyClient).to receive(:get_request_count).and_return(0) - end - it 'does not raise an error if calls_gitaly is false' do - expect { no_gitaly_field.send(:calls_gitaly_check) }.not_to raise_error - end - - it 'raises an error if calls_gitaly: true appears' do - expect { gitaly_field.send(:calls_gitaly_check) }.to raise_error(/please add `calls_gitaly: true`/) + expect { no_gitaly_field.send(:calls_gitaly_check, 0) }.not_to raise_error end end context 'if there is at least 1 Gitaly call' do - before do - allow(Gitlab::GitalyClient).to receive(:get_request_count).and_return(1) + it 'does not raise an error if calls_gitaly is true' do + expect { gitaly_field.send(:calls_gitaly_check, 1) }.not_to raise_error end - it 'does not raise an error if calls_gitaly is true' do - expect { gitaly_field.send(:calls_gitaly_check) }.not_to raise_error + it 'raises an error if calls_gitaly: is false or not defined' do + expect { no_gitaly_field.send(:calls_gitaly_check, 1) }.to raise_error(/please add `calls_gitaly: true`/) end end end |