-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathperfetto_sampler_spec.rb
More file actions
50 lines (42 loc) · 1.75 KB
/
perfetto_sampler_spec.rb
File metadata and controls
50 lines (42 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# frozen_string_literal: true
require "spec_helper"
describe GraphQL::Tracing::PerfettoSampler do
class SamplerSchema < GraphQL::Schema
class Query < GraphQL::Schema::Object
field :truthy, Boolean, fallback_value: true
end
query(Query)
use GraphQL::Tracing::PerfettoSampler, memory: true
end
before do
SamplerSchema.perfetto_sampler.delete_all_traces
end
it "runs when the configured trace mode is set" do
skip("Currently disabled")
assert_equal 0, SamplerSchema.perfetto_sampler.traces.size
res = SamplerSchema.execute("{ truthy }")
assert_equal true, res["data"]["truthy"]
assert_equal 0, SamplerSchema.perfetto_sampler.traces.size
SamplerSchema.execute("{ truthy }", context: { trace_mode: :perfetto_sample })
assert_equal 1, SamplerSchema.perfetto_sampler.traces.size
end
it "calls through to storage for access methods" do
skip("Currently disabled")
SamplerSchema.execute("{ truthy }", context: { trace_mode: :perfetto_sample })
id = SamplerSchema.perfetto_sampler.traces.first.id
assert_kind_of GraphQL::Tracing::PerfettoSampler::StoredTrace, SamplerSchema.perfetto_sampler.find_trace(id)
SamplerSchema.perfetto_sampler.delete_trace(id)
assert_equal 0, SamplerSchema.perfetto_sampler.traces.size
SamplerSchema.execute("{ truthy }", context: { trace_mode: :perfetto_sample })
assert_equal 1, SamplerSchema.perfetto_sampler.traces.size
SamplerSchema.perfetto_sampler.delete_all_traces
end
it "raises when no storage is configured" do
err = assert_raises ArgumentError do
Class.new(GraphQL::Schema) do
use GraphQL::Tracing::PerfettoSampler, active_record: false
end
end
assert_equal "A storage option must be chosen", err.message
end
end