diff options
Diffstat (limited to 'spec/lib/gitlab/graphql_logger_spec.rb')
-rw-r--r-- | spec/lib/gitlab/graphql_logger_spec.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/lib/gitlab/graphql_logger_spec.rb b/spec/lib/gitlab/graphql_logger_spec.rb index aeeed0b2ca1..4157bb86f1c 100644 --- a/spec/lib/gitlab/graphql_logger_spec.rb +++ b/spec/lib/gitlab/graphql_logger_spec.rb @@ -12,4 +12,26 @@ describe Gitlab::GraphqlLogger do subject.info('hello world') subject.error('hello again') end + + context 'logging a GraphQL query' do + let(:query) { File.read(Rails.root.join('spec/fixtures/api/graphql/introspection.graphql')) } + it 'logs a query from JSON' do + analyzer_memo = { + query_string: query, + variables: {}, + complexity: 181, + depth: 0, + duration: "7ms" + } + output = subject.format_message('INFO', now, 'test', analyzer_memo) + data = JSON.parse(output) + + expect(data['severity']).to eq('INFO') + expect(data['time']).to eq(now.utc.iso8601(3)) + expect(data['complexity']).to eq(181) + expect(data['variables']).to eq({}) + expect(data['depth']).to eq(0) + expect(data['duration']).to eq("7ms") + end + end end |