Skip to content

Commit 334a7d6

Browse files
committed
Add tests
1 parent 4293e86 commit 334a7d6

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

sentry-ruby/spec/sentry/structured_logger_spec.rb

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,45 @@
6767
expect(log_event[:attributes]["sentry.message.parameter.1"]).to eql({ value: "Monday", type: "string" })
6868
end
6969

70+
it "logs with nested hash attributes" do
71+
attributes = { number: 312, string: "hello" }
72+
73+
Sentry.logger.public_send(level, "Hello world", extra: attributes)
74+
75+
expect(sentry_logs).to_not be_empty
76+
77+
log_event = sentry_logs.last
78+
79+
expect(log_event[:level]).to eql(level)
80+
expect(log_event[:attributes][:extra]).to eql({ type: "string", value: attributes.to_json })
81+
end
82+
83+
it "logs with array attributes" do
84+
attributes = [1, 2, 3, "hello"]
85+
86+
Sentry.logger.public_send(level, "Hello world", extra: attributes)
87+
88+
expect(sentry_logs).to_not be_empty
89+
90+
log_event = sentry_logs.last
91+
92+
expect(log_event[:level]).to eql(level)
93+
expect(log_event[:attributes][:extra]).to eql({ type: "string", value: attributes.to_json })
94+
end
95+
96+
it "logs with date in attributes" do
97+
attributes = Date.today
98+
99+
Sentry.logger.public_send(level, "Hello world", extra: attributes)
100+
101+
expect(sentry_logs).to_not be_empty
102+
103+
log_event = sentry_logs.last
104+
105+
expect(log_event[:level]).to eql(level)
106+
expect(log_event[:attributes][:extra]).to eql({ type: "string", value: attributes.to_json })
107+
end
108+
70109
it "logs with hash-based template parameters" do
71110
Sentry.logger.public_send(level, "Hello %{name}, it is %{day}", name: "Jane", day: "Monday")
72111

0 commit comments

Comments
 (0)