@@ -198,4 +198,37 @@ void main() {
198198
199199 expect (options.enableDartSymbolication, true );
200200 });
201+
202+ test ('parsedDsn is correctly parsed and cached' , () {
203+ final options = defaultTestOptions ();
204+
205+ // Access parsedDsn for the first time
206+ final parsedDsn1 = options.parsedDsn;
207+
208+ // Access parsedDsn again
209+ final parsedDsn2 = options.parsedDsn;
210+
211+ // Should return the same instance since it's cached
212+ expect (identical (parsedDsn1, parsedDsn2), isTrue);
213+
214+ // Verify the parsed DSN fields
215+ final manuallyParsedDsn = Dsn .parse (options.dsn! );
216+ expect (parsedDsn1.publicKey, manuallyParsedDsn.publicKey);
217+ expect (parsedDsn1.postUri, manuallyParsedDsn.postUri);
218+ expect (parsedDsn1.secretKey, manuallyParsedDsn.secretKey);
219+ expect (parsedDsn1.projectId, manuallyParsedDsn.projectId);
220+ expect (parsedDsn1.uri, manuallyParsedDsn.uri);
221+ });
222+
223+ test ('parsedDsn throws when DSN is null' , () {
224+ final options = defaultTestOptions ()..dsn = null ;
225+
226+ expect (() => options.parsedDsn, throwsA (isA <StateError >()));
227+ });
228+
229+ test ('parsedDsn throws when DSN is empty' , () {
230+ final options = defaultTestOptions ()..dsn = '' ;
231+
232+ expect (() => options.parsedDsn, throwsA (isA <StateError >()));
233+ });
201234}
0 commit comments