@@ -94,6 +94,17 @@ defmodule Sentry.EventTest do
9494 assert map_size ( event . modules ) > 0
9595 end
9696
97+ test "includes the config defaults" do
98+ put_test_config (
99+ tags: % { "test-tag" => "test-value" } ,
100+ extra: % { "some-data": "with-a-value" }
101+ )
102+
103+ assert % Event { } = event = Event . create_event ( [ ] )
104+ assert event . tags == % { "test-tag" => "test-value" }
105+ assert event . extra == % { "some-data": "with-a-value" }
106+ end
107+
97108 test "fills in passed-in options" do
98109 assert % Event { } = event = Event . create_event ( level: :info )
99110 assert event . level == :info
@@ -144,6 +155,50 @@ defmodule Sentry.EventTest do
144155 end
145156 end
146157
158+ test "fills in `:tags` and `:extra` with precedence of options > context > config" do
159+ put_test_config (
160+ tags: % {
161+ "not-overriden" => "config" ,
162+ "overriden-by-context" => "config" ,
163+ "overriden-by-options" => "config"
164+ } ,
165+ extra: % {
166+ "not-overriden": "config" ,
167+ "overriden-by-context": "config" ,
168+ "overriden-by-options": "config"
169+ }
170+ )
171+
172+ Sentry.Context . set_tags_context ( % {
173+ "overriden-by-context" => "context" ,
174+ "overriden-by-options" => "context"
175+ } )
176+
177+ Sentry.Context . set_extra_context ( % {
178+ "overriden-by-context": "context" ,
179+ "overriden-by-options": "context"
180+ } )
181+
182+ assert % Event { } =
183+ event =
184+ Event . create_event (
185+ tags: % { "overriden-by-options" => "options" } ,
186+ extra: % { "overriden-by-options": "options" }
187+ )
188+
189+ assert event . tags == % {
190+ "not-overriden" => "config" ,
191+ "overriden-by-context" => "context" ,
192+ "overriden-by-options" => "options"
193+ }
194+
195+ assert event . extra == % {
196+ "not-overriden": "config" ,
197+ "overriden-by-context": "context" ,
198+ "overriden-by-options": "options"
199+ }
200+ end
201+
147202 test "supports the :fingerprint option" do
148203 assert % Event { } = event = Event . create_event ( fingerprint: [ "foo" , "bar" ] )
149204 assert event . fingerprint == [ "foo" , "bar" ]
0 commit comments