File tree Expand file tree Collapse file tree 1 file changed +23
-2
lines changed
src/test/java/com/spotify/github/tracing Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Original file line number Diff line number Diff line change 2727
2828import java .util .Collections ;
2929
30- import static org .mockito .Mockito .mock ;
31- import static org .mockito .Mockito .verify ;
30+ import static org .mockito .Mockito .*;
3231
3332class OpenTelemetrySpanTest {
3433 private final io .opentelemetry .api .trace .Span wrapped = mock (io .opentelemetry .api .trace .Span .class );
@@ -66,4 +65,26 @@ public void failOnServerError() {
6665 verify (wrapped ).end ();
6766 }
6867
68+ @ Test
69+ public void failWithNullThrowable () {
70+ final Span span = new OpenTelemetrySpan (wrapped );
71+ span .failure (null );
72+ span .close ();
73+
74+ verify (wrapped ).setStatus (StatusCode .UNSET );
75+ verify (wrapped , never ()).setAttribute (anyString (), any ());
76+ verify (wrapped ).end ();
77+ }
78+
79+ @ Test
80+ public void failWithNonRequestNotOkException () {
81+ final Span span = new OpenTelemetrySpan (wrapped );
82+ span .failure (new RuntimeException ("Unexpected error" ));
83+ span .close ();
84+
85+ verify (wrapped ).setStatus (StatusCode .UNSET );
86+ verify (wrapped , never ()).setAttribute ("http.status_code" , 404 );
87+ verify (wrapped , never ()).setAttribute ("error" , true );
88+ verify (wrapped ).end ();
89+ }
6990}
You can’t perform that action at this time.
0 commit comments