appsignal 4.0.4-java → 4.0.5-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,86 +1,69 @@
1
1
  describe Appsignal::CheckIn::Cron do
2
+ let(:log_stream) { std_stream }
3
+ let(:logs) { log_contents(log_stream) }
4
+ let(:appsignal_options) { {} }
2
5
  let(:config) { project_fixture_config }
3
6
  let(:cron_checkin) { described_class.new(:identifier => "cron-checkin-name") }
4
7
  let(:transmitter) { Appsignal::Transmitter.new("https://checkin-endpoint.invalid") }
5
8
  let(:scheduler) { Appsignal::CheckIn::Scheduler.new }
6
9
 
7
10
  before do
8
- allow(Appsignal).to receive(:active?).and_return(true)
9
- config.logger = Logger.new(StringIO.new)
11
+ start_agent(
12
+ :options => appsignal_options,
13
+ :internal_logger => test_logger(log_stream)
14
+ )
10
15
  allow(Appsignal::CheckIn).to receive(:scheduler).and_return(scheduler)
11
16
  allow(Appsignal::CheckIn).to receive(:transmitter).and_return(transmitter)
12
17
  end
18
+ after { stop_scheduler }
13
19
 
14
- after do
20
+ def stop_scheduler
15
21
  scheduler.stop
16
22
  end
17
23
 
18
24
  describe "when Appsignal is not active" do
19
- it "should not transmit any events" do
20
- allow(Appsignal).to receive(:active?).and_return(false)
25
+ let(:appsignal_options) { { :active => false } }
21
26
 
22
- expect(Appsignal.internal_logger).to receive(:debug).with(satisfy do |message|
23
- message.include?("Cannot transmit cron check-in `cron-checkin-name` start event") &&
24
- message.include?("AppSignal is not active")
25
- end)
27
+ it "does not transmit any events" do
28
+ expect(Appsignal).to_not be_started
26
29
 
27
30
  cron_checkin.start
28
-
29
- expect(Appsignal.internal_logger).to receive(:debug).with(satisfy do |message|
30
- message.include?("Cannot transmit cron check-in `cron-checkin-name` finish event") &&
31
- message.include?("AppSignal is not active")
32
- end)
33
-
34
31
  cron_checkin.finish
35
-
36
- expect(transmitter).not_to receive(:transmit)
37
-
38
- scheduler.stop
32
+ stop_scheduler
33
+
34
+ expect(logs).to contains_log(
35
+ :debug,
36
+ /Cannot transmit cron check-in `cron-checkin-name` start event .+: AppSignal is not active/
37
+ )
38
+ expect(logs).to contains_log(
39
+ :debug,
40
+ /Cannot transmit cron check-in `cron-checkin-name` finish event .+: AppSignal is not active/
41
+ )
39
42
  end
40
43
  end
41
44
 
42
45
  describe "when AppSignal is stopped" do
43
- it "should not transmit any events" do
44
- expect(transmitter).not_to receive(:transmit)
45
-
46
- expect(Appsignal.internal_logger).to receive(:debug).with("Stopping AppSignal")
47
-
46
+ it "does not transmit any events" do
48
47
  Appsignal.stop
49
48
 
50
- expect(Appsignal.internal_logger).to receive(:debug).with(satisfy do |message|
51
- message.include?("Cannot transmit cron check-in `cron-checkin-name` start event") &&
52
- message.include?("AppSignal is stopped")
53
- end)
54
-
55
49
  cron_checkin.start
56
-
57
- expect(Appsignal.internal_logger).to receive(:debug).with(satisfy do |message|
58
- message.include?("Cannot transmit cron check-in `cron-checkin-name` finish event") &&
59
- message.include?("AppSignal is stopped")
60
- end)
61
-
62
50
  cron_checkin.finish
63
51
 
64
- expect(Appsignal.internal_logger).to receive(:debug).with("Stopping AppSignal")
65
-
66
- Appsignal.stop
52
+ expect(logs).to contains_log(
53
+ :debug,
54
+ "Cannot transmit cron check-in `cron-checkin-name` start event"
55
+ )
56
+ expect(logs).to contains_log(
57
+ :debug,
58
+ "Cannot transmit cron check-in `cron-checkin-name` finish event"
59
+ )
67
60
  end
68
61
  end
69
62
 
70
63
  describe "#start" do
71
- it "should send a cron check-in start" do
72
- expect(Appsignal.internal_logger).not_to receive(:error)
73
-
74
- expect(Appsignal.internal_logger).to receive(:debug).with(satisfy do |message|
75
- message.include?("Scheduling cron check-in `cron-checkin-name` start event")
76
- end)
77
-
64
+ it "sends a cron check-in start" do
78
65
  cron_checkin.start
79
66
 
80
- expect(Appsignal.internal_logger).to receive(:debug).with(satisfy do |message|
81
- message.include?("Transmitted cron check-in `cron-checkin-name` start event")
82
- end)
83
-
84
67
  expect(transmitter).to receive(:transmit).with([hash_including(
85
68
  :identifier => "cron-checkin-name",
86
69
  :kind => "start",
@@ -88,20 +71,21 @@ describe Appsignal::CheckIn::Cron do
88
71
  )], :format => :ndjson).and_return(Net::HTTPResponse.new(nil, "200", nil))
89
72
 
90
73
  scheduler.stop
91
- end
92
74
 
93
- it "should log an error if it fails" do
94
- expect(Appsignal.internal_logger).to receive(:debug).with(satisfy do |message|
95
- message.include?("Scheduling cron check-in `cron-checkin-name` start event")
96
- end)
75
+ expect(logs).to_not contains_log(:error)
76
+ expect(logs).to contains_log(
77
+ :debug,
78
+ "Scheduling cron check-in `cron-checkin-name` start event"
79
+ )
80
+ expect(logs).to contains_log(
81
+ :debug,
82
+ "Transmitted cron check-in `cron-checkin-name` start event"
83
+ )
84
+ end
97
85
 
86
+ it "logs an error if it fails" do
98
87
  cron_checkin.start
99
88
 
100
- expect(Appsignal.internal_logger).to receive(:error).with(satisfy do |message|
101
- message.include?("Failed to transmit cron check-in `cron-checkin-name` start event") &&
102
- message.include?("499 status code")
103
- end)
104
-
105
89
  expect(transmitter).to receive(:transmit).with([hash_including(
106
90
  :identifier => "cron-checkin-name",
107
91
  :kind => "start",
@@ -109,23 +93,22 @@ describe Appsignal::CheckIn::Cron do
109
93
  )], :format => :ndjson).and_return(Net::HTTPResponse.new(nil, "499", nil))
110
94
 
111
95
  scheduler.stop
96
+
97
+ expect(logs).to contains_log(
98
+ :debug,
99
+ "Scheduling cron check-in `cron-checkin-name` start event"
100
+ )
101
+ expect(logs).to contains_log(
102
+ :error,
103
+ /Failed to transmit cron check-in `cron-checkin-name` start event .+: 499 status code/
104
+ )
112
105
  end
113
106
  end
114
107
 
115
108
  describe "#finish" do
116
- it "should send a cron check-in finish" do
117
- expect(Appsignal.internal_logger).not_to receive(:error)
118
-
119
- expect(Appsignal.internal_logger).to receive(:debug).with(satisfy do |message|
120
- message.include?("Scheduling cron check-in `cron-checkin-name` finish event")
121
- end)
122
-
109
+ it "sends a cron check-in finish" do
123
110
  cron_checkin.finish
124
111
 
125
- expect(Appsignal.internal_logger).to receive(:debug).with(satisfy do |message|
126
- message.include?("Transmitted cron check-in `cron-checkin-name` finish event")
127
- end)
128
-
129
112
  expect(transmitter).to receive(:transmit).with([hash_including(
130
113
  :identifier => "cron-checkin-name",
131
114
  :kind => "finish",
@@ -133,20 +116,20 @@ describe Appsignal::CheckIn::Cron do
133
116
  )], :format => :ndjson).and_return(Net::HTTPResponse.new(nil, "200", nil))
134
117
 
135
118
  scheduler.stop
119
+ expect(logs).to_not contains_log(:error)
120
+ expect(logs).to contains_log(
121
+ :debug,
122
+ "Scheduling cron check-in `cron-checkin-name` finish event"
123
+ )
124
+ expect(logs).to contains_log(
125
+ :debug,
126
+ "Transmitted cron check-in `cron-checkin-name` finish event"
127
+ )
136
128
  end
137
129
 
138
- it "should log an error if it fails" do
139
- expect(Appsignal.internal_logger).to receive(:debug).with(satisfy do |message|
140
- message.include?("Scheduling cron check-in `cron-checkin-name` finish event")
141
- end)
142
-
130
+ it "logs an error if it fails" do
143
131
  cron_checkin.finish
144
132
 
145
- expect(Appsignal.internal_logger).to receive(:error).with(satisfy do |message|
146
- message.include?("Failed to transmit cron check-in `cron-checkin-name` finish event") &&
147
- message.include?("499 status code")
148
- end)
149
-
150
133
  expect(transmitter).to receive(:transmit).with([hash_including(
151
134
  :identifier => "cron-checkin-name",
152
135
  :kind => "finish",
@@ -154,12 +137,21 @@ describe Appsignal::CheckIn::Cron do
154
137
  )], :format => :ndjson).and_return(Net::HTTPResponse.new(nil, "499", nil))
155
138
 
156
139
  scheduler.stop
140
+
141
+ expect(logs).to contains_log(
142
+ :debug,
143
+ "Scheduling cron check-in `cron-checkin-name` finish event"
144
+ )
145
+ expect(logs).to contains_log(
146
+ :error,
147
+ /Failed to transmit cron check-in `cron-checkin-name` finish event .+: 499 status code/
148
+ )
157
149
  end
158
150
  end
159
151
 
160
152
  describe ".cron" do
161
153
  describe "when a block is given" do
162
- it "should send a cron check-in start and finish and return the block output" do
154
+ it "sends a cron check-in start and finish and return the block output" do
163
155
  expect(scheduler).to receive(:schedule).with(hash_including(
164
156
  :kind => "start",
165
157
  :identifier => "cron-checkin-with-block",
@@ -176,7 +168,7 @@ describe Appsignal::CheckIn::Cron do
176
168
  expect(output).to eq("output")
177
169
  end
178
170
 
179
- it "should not send a cron check-in finish event when an error is raised" do
171
+ it "does not send a cron check-in finish event when an error is raised" do
180
172
  expect(scheduler).to receive(:schedule).with(hash_including(
181
173
  :kind => "start",
182
174
  :identifier => "cron-checkin-with-block",
@@ -196,7 +188,7 @@ describe Appsignal::CheckIn::Cron do
196
188
  end
197
189
 
198
190
  describe "when no block is given" do
199
- it "should only send a cron check-in finish event" do
191
+ it "only sends a cron check-in finish event" do
200
192
  expect(scheduler).to receive(:schedule).with(hash_including(
201
193
  :kind => "finish",
202
194
  :identifier => "cron-checkin-without-block",
@@ -2,10 +2,13 @@ describe Appsignal::CheckIn::Scheduler do
2
2
  include WaitForHelper
3
3
  include TakeAtMostHelper
4
4
 
5
+ let(:log_stream) { std_stream }
6
+ let(:logs) { log_contents(log_stream) }
7
+ let(:appsignal_options) { {} }
5
8
  let(:transmitter) { Appsignal::Transmitter.new("http://checkin-endpoint.invalid") }
6
9
 
7
10
  before do
8
- allow(Appsignal).to receive(:active?).and_return(true)
11
+ start_agent(:options => appsignal_options, :internal_logger => test_logger(log_stream))
9
12
  allow(transmitter).to receive(:transmit).and_return(Net::HTTPSuccess.new("1.1", 200, "OK"))
10
13
  allow(Appsignal::CheckIn).to receive(:transmitter).and_return(transmitter)
11
14
  allow(Appsignal::CheckIn).to receive(:scheduler).and_return(subject)
@@ -76,23 +79,18 @@ describe Appsignal::CheckIn::Scheduler do
76
79
  :kind => "finish"
77
80
  )], :format => :ndjson)
78
81
 
79
- expect(Appsignal.internal_logger).to receive(:debug).with(satisfy do |message|
80
- message.include?("Scheduling cron check-in `test` finish event")
81
- end)
82
-
83
82
  expect(subject.events).to be_empty
84
83
 
85
84
  Appsignal::CheckIn.cron("test")
86
85
 
87
86
  expect(subject.events).not_to be_empty
88
87
 
89
- expect(Appsignal.internal_logger).to receive(:debug).with(satisfy do |message|
90
- message.include?("Transmitted cron check-in `test` finish event")
91
- end)
92
-
93
88
  wait_for("the event to be transmitted") { subject.transmitted == 1 }
94
89
 
95
90
  expect(subject.events).to be_empty
91
+
92
+ expect(logs).to contains_log(:debug, "Scheduling cron check-in `test` finish event")
93
+ expect(logs).to contains_log(:debug, "Transmitted cron check-in `test` finish event")
96
94
  end
97
95
 
98
96
  it "waits for the event to be transmitted when stopped" do
@@ -109,16 +107,8 @@ describe Appsignal::CheckIn::Scheduler do
109
107
  :kind => "finish"
110
108
  )], :format => :ndjson)
111
109
 
112
- expect(Appsignal.internal_logger).to receive(:debug).with(satisfy do |message|
113
- message.include?("Scheduling cron check-in `test` finish event")
114
- end)
115
-
116
110
  Appsignal::CheckIn.cron("test")
117
111
 
118
- expect(Appsignal.internal_logger).to receive(:debug).with(satisfy do |message|
119
- message.include?("Transmitted cron check-in `test` finish event")
120
- end)
121
-
122
112
  expect(subject.events).not_to be_empty
123
113
 
124
114
  take_at_most(0.1) do
@@ -130,6 +120,9 @@ describe Appsignal::CheckIn::Scheduler do
130
120
  expect(subject.transmitted).to eq(1)
131
121
 
132
122
  expect(subject.events).to be_empty
123
+
124
+ expect(logs).to contains_log(:debug, "Scheduling cron check-in `test` finish event")
125
+ expect(logs).to contains_log(:debug, "Transmitted cron check-in `test` finish event")
133
126
  end
134
127
 
135
128
  it "can be stopped more than once" do
@@ -249,16 +242,8 @@ describe Appsignal::CheckIn::Scheduler do
249
242
  it "transmits the other events after the debounce interval" do
250
243
  expect(transmitter).to receive(:transmit)
251
244
 
252
- expect(Appsignal.internal_logger).to receive(:debug).with(satisfy do |message|
253
- message.include?("Scheduling cron check-in `first` finish event")
254
- end)
255
-
256
245
  Appsignal::CheckIn.cron("first")
257
246
 
258
- expect(Appsignal.internal_logger).to receive(:debug).with(satisfy do |message|
259
- message.include?("Transmitted cron check-in `first` finish event")
260
- end)
261
-
262
247
  wait_for("the first event to be transmitted") { subject.transmitted == 1 }
263
248
 
264
249
  expect(transmitter).to receive(:transmit).with(
@@ -271,27 +256,20 @@ describe Appsignal::CheckIn::Scheduler do
271
256
  end, :format => :ndjson
272
257
  )
273
258
 
274
- expect(Appsignal.internal_logger).to receive(:debug).with(satisfy do |message|
275
- message.include?("Scheduling cron check-in `second` finish event")
276
- end)
277
-
278
259
  Appsignal::CheckIn.cron("second")
279
-
280
- expect(Appsignal.internal_logger).to receive(:debug).with(satisfy do |message|
281
- message.include?("Scheduling cron check-in `third` finish event")
282
- end)
283
-
284
260
  Appsignal::CheckIn.cron("third")
285
261
 
286
262
  expect(subject.events).to_not be_empty
287
263
 
288
- expect(Appsignal.internal_logger).to receive(:debug).with(
289
- "Transmitted 2 check-in events"
290
- )
291
-
292
264
  wait_for("the other events to be transmitted") { subject.transmitted == 2 }
293
265
 
294
266
  expect(subject.events).to be_empty
267
+
268
+ expect(logs).to contains_log(:debug, "Scheduling cron check-in `first` finish event")
269
+ expect(logs).to contains_log(:debug, "Transmitted cron check-in `first` finish event")
270
+ expect(logs).to contains_log(:debug, "Scheduling cron check-in `second` finish event")
271
+ expect(logs).to contains_log(:debug, "Scheduling cron check-in `third` finish event")
272
+ expect(logs).to contains_log(:debug, "Transmitted 2 check-in events")
295
273
  end
296
274
 
297
275
  it "transmits the other events when stopped" do
@@ -303,16 +281,8 @@ describe Appsignal::CheckIn::Scheduler do
303
281
 
304
282
  expect(transmitter).to receive(:transmit)
305
283
 
306
- expect(Appsignal.internal_logger).to receive(:debug).with(satisfy do |message|
307
- message.include?("Scheduling cron check-in `first` finish event")
308
- end)
309
-
310
284
  Appsignal::CheckIn.cron("first")
311
285
 
312
- expect(Appsignal.internal_logger).to receive(:debug).with(satisfy do |message|
313
- message.include?("Transmitted cron check-in `first` finish event")
314
- end)
315
-
316
286
  wait_for("the event to be transmitted") { subject.transmitted == 1 }
317
287
 
318
288
  expect(transmitter).to receive(:transmit).with(
@@ -325,29 +295,22 @@ describe Appsignal::CheckIn::Scheduler do
325
295
  end, :format => :ndjson
326
296
  )
327
297
 
328
- expect(Appsignal.internal_logger).to receive(:debug).with(satisfy do |message|
329
- message.include?("Scheduling cron check-in `second` finish event")
330
- end)
331
-
332
298
  Appsignal::CheckIn.cron("second")
333
-
334
- expect(Appsignal.internal_logger).to receive(:debug).with(satisfy do |message|
335
- message.include?("Scheduling cron check-in `third` finish event")
336
- end)
337
-
338
299
  Appsignal::CheckIn.cron("third")
339
300
 
340
301
  expect(subject.events).to_not be_empty
341
302
 
342
- expect(Appsignal.internal_logger).to receive(:debug).with(
343
- "Transmitted 2 check-in events"
344
- )
345
-
346
303
  subject.stop
347
304
 
348
305
  wait_for("the other events to be transmitted") { subject.transmitted == 2 }
349
306
 
350
307
  expect(subject.events).to be_empty
308
+
309
+ expect(logs).to contains_log(:debug, "Scheduling cron check-in `first` finish event")
310
+ expect(logs).to contains_log(:debug, "Transmitted cron check-in `first` finish event")
311
+ expect(logs).to contains_log(:debug, "Scheduling cron check-in `second` finish event")
312
+ expect(logs).to contains_log(:debug, "Scheduling cron check-in `third` finish event")
313
+ expect(logs).to contains_log(:debug, "Transmitted 2 check-in events")
351
314
  end
352
315
  end
353
316
  end
@@ -364,27 +327,27 @@ describe Appsignal::CheckIn::Scheduler do
364
327
  :kind => "start"
365
328
  )], :format => :ndjson)
366
329
 
367
- expect(Appsignal.internal_logger).to receive(:debug).with(
368
- "Scheduling cron check-in `test` start event (digest #{cron.digest}) to be transmitted"
369
- )
370
-
371
330
  cron.start
331
+ cron.start
332
+
333
+ wait_for("the event to be transmitted") { subject.transmitted == 1 }
372
334
 
373
- expect(Appsignal.internal_logger).to receive(:debug).with(
335
+ expect(logs).to contains_log(
336
+ :debug,
374
337
  "Scheduling cron check-in `test` start event (digest #{cron.digest}) to be transmitted"
375
338
  )
376
-
377
- expect(Appsignal.internal_logger).to receive(:debug).with(
339
+ expect(logs).to contains_log(
340
+ :debug,
341
+ "Scheduling cron check-in `test` start event (digest #{cron.digest}) to be transmitted"
342
+ )
343
+ expect(logs).to contains_log(
344
+ :debug,
378
345
  "Replacing previously scheduled cron check-in `test` start event (digest #{cron.digest})"
379
346
  )
380
-
381
- cron.start
382
-
383
- expect(Appsignal.internal_logger).to receive(:debug).with(
347
+ expect(logs).to contains_log(
348
+ :debug,
384
349
  "Transmitted cron check-in `test` start event (digest #{cron.digest})"
385
350
  )
386
-
387
- wait_for("the event to be transmitted") { subject.transmitted == 1 }
388
351
  end
389
352
  end
390
353
 
@@ -394,31 +357,31 @@ describe Appsignal::CheckIn::Scheduler do
394
357
 
395
358
  subject.stop
396
359
 
397
- expect(Appsignal.internal_logger).to receive(:debug).with(satisfy do |message|
398
- message.include?("Cannot transmit cron check-in `test` finish event") &&
399
- message.include?("AppSignal is stopped")
400
- end)
401
-
402
360
  Appsignal::CheckIn.cron("test")
403
361
 
404
362
  expect(subject.events).to be_empty
363
+
364
+ expect(logs).to contains_log(
365
+ :debug,
366
+ /Cannot transmit cron check-in `test` finish event .+: AppSignal is stopped/
367
+ )
405
368
  end
406
369
  end
407
370
 
408
371
  describe "when AppSignal is not active" do
409
- it "does not schedule any events to be transmitted" do
410
- allow(Appsignal).to receive(:active?).and_return(false)
372
+ let(:appsignal_options) { { :active => false } }
411
373
 
374
+ it "does not schedule any events to be transmitted" do
412
375
  subject.stop
413
376
 
414
- expect(Appsignal.internal_logger).to receive(:debug).with(satisfy do |message|
415
- message.include?("Cannot transmit cron check-in `test` finish event") &&
416
- message.include?("AppSignal is not active")
417
- end)
418
-
419
377
  Appsignal::CheckIn.cron("test")
420
378
 
421
379
  expect(subject.events).to be_empty
380
+
381
+ expect(logs).to contains_log(
382
+ :debug,
383
+ /Cannot transmit cron check-in `test` finish event .+: AppSignal is not active/
384
+ )
422
385
  end
423
386
  end
424
387
 
@@ -430,11 +393,6 @@ describe Appsignal::CheckIn::Scheduler do
430
393
 
431
394
  Appsignal::CheckIn.cron("first")
432
395
 
433
- expect(Appsignal.internal_logger).to receive(:error).with(satisfy do |message|
434
- message.include?("Failed to transmit cron check-in `first` finish event") &&
435
- message.include?("404 status code")
436
- end)
437
-
438
396
  wait_for("the first event to be transmitted") { subject.transmitted == 1 }
439
397
 
440
398
  expect(transmitter).to receive(:transmit).and_return(
@@ -443,13 +401,16 @@ describe Appsignal::CheckIn::Scheduler do
443
401
 
444
402
  Appsignal::CheckIn.cron("second")
445
403
 
446
- expect(Appsignal.internal_logger).not_to receive(:error)
447
-
448
- expect(Appsignal.internal_logger).to receive(:debug).with(satisfy do |message|
449
- message.include?("Transmitted cron check-in `second` finish event")
450
- end)
451
-
452
404
  wait_for("the second event to be transmitted") { subject.transmitted == 2 }
405
+
406
+ expect(logs).to contains_log(
407
+ :error,
408
+ /Failed to transmit cron check-in `first` finish event .+: 404 status code/
409
+ )
410
+ expect(logs).to contains_log(
411
+ :debug,
412
+ "Transmitted cron check-in `second` finish event"
413
+ )
453
414
  end
454
415
  end
455
416
 
@@ -459,11 +420,6 @@ describe Appsignal::CheckIn::Scheduler do
459
420
 
460
421
  Appsignal::CheckIn.cron("first")
461
422
 
462
- expect(Appsignal.internal_logger).to receive(:error).with(satisfy do |message|
463
- message.include?("Failed to transmit cron check-in `first` finish event") &&
464
- message.include?("Something went wrong")
465
- end)
466
-
467
423
  wait_for("the first event to be transmitted") { subject.transmitted == 1 }
468
424
 
469
425
  expect(transmitter).to receive(:transmit).and_return(
@@ -472,13 +428,16 @@ describe Appsignal::CheckIn::Scheduler do
472
428
 
473
429
  Appsignal::CheckIn.cron("second")
474
430
 
475
- expect(Appsignal.internal_logger).not_to receive(:error)
476
-
477
- expect(Appsignal.internal_logger).to receive(:debug).with(satisfy do |message|
478
- message.include?("Transmitted cron check-in `second` finish event")
479
- end)
480
-
481
431
  wait_for("the second event to be transmitted") { subject.transmitted == 2 }
432
+
433
+ expect(logs).to contains_log(
434
+ :error,
435
+ /Failed to transmit cron check-in `first` finish event .+: Something went wrong/
436
+ )
437
+ expect(logs).to contains_log(
438
+ :debug,
439
+ "Transmitted cron check-in `second` finish event"
440
+ )
482
441
  end
483
442
  end
484
443
  end
@@ -1,5 +1,18 @@
1
1
  describe Appsignal::Config do
2
2
  describe ".add_loader_defaults" do
3
+ context "when the config is initialized" do
4
+ before { Appsignal.configure(:test) }
5
+
6
+ it "logs a warning" do
7
+ logs = capture_logs { described_class.add_loader_defaults(:loader1) }
8
+
9
+ expect(logs).to contains_log(
10
+ :warn,
11
+ "The config defaults from the 'loader1' loader are ignored"
12
+ )
13
+ end
14
+ end
15
+
3
16
  it "adds loader defaults to the list" do
4
17
  described_class.add_loader_defaults(:loader1)
5
18
 
@@ -40,6 +40,17 @@ describe Appsignal::Hooks::AtExit::AtExitCallback do
40
40
  Appsignal::Hooks::AtExit::AtExitCallback.call
41
41
  end
42
42
 
43
+ it "reports no transaction if the process didn't exit with an error" do
44
+ logs =
45
+ capture_logs do
46
+ expect do
47
+ call_callback
48
+ end.to_not(change { created_transactions.count })
49
+ end
50
+
51
+ expect(logs).to_not contains_log(:error, "Appsignal.report_error: Cannot add error.")
52
+ end
53
+
43
54
  it "reports an error if there's an unhandled error" do
44
55
  expect do
45
56
  with_error(ExampleException, "error message") do