Skip to content

Commit f3c95de

Browse files
committed
fix(tests): Account for initialization logic
1 parent 626d425 commit f3c95de

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/cadet/logger/cloudwatch_logger_test.exs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,26 @@ defmodule Cadet.Logger.CloudWatchLoggerTest do
2121
metadata: [:request_id]
2222
)
2323

24+
# Mock the DescribeLogStreams request during initialization
25+
expect(ExAwsMock, :request, fn %ExAws.Operation.JSON{} = op
26+
when op.headers == [
27+
{"x-amz-target", "Logs_20140328.DescribeLogStreams"},
28+
{"content-type", "application/x-amz-json-1.1"}
29+
] ->
30+
# Simulate no existing log streams
31+
{:ok, %{"logStreams" => []}}
32+
end)
33+
34+
# Mock the CreateLogStream request during initialization
35+
expect(ExAwsMock, :request, fn %ExAws.Operation.JSON{} = op
36+
when op.headers == [
37+
{"x-amz-target", "Logs_20140328.CreateLogStream"},
38+
{"content-type", "application/x-amz-json-1.1"}
39+
] ->
40+
# Simulate successful log stream creation
41+
{:ok, %{}}
42+
end)
43+
2444
LoggerBackends.add({CloudWatchLogger, :cloudwatch_logger})
2545

2646
Logger.configure_backend(:console, level: :error, format: "$metadata[$level] $message\n")

0 commit comments

Comments
 (0)