@@ -77,6 +77,28 @@ public void CustomSmartSubtransportTest(string scheme, string url)
77
77
}
78
78
}
79
79
80
+ [ Fact ]
81
+ public void ExceptionPropogationTest ( )
82
+ {
83
+ var scd = BuildSelfCleaningDirectory ( ) ;
84
+ var url = "https://github.com/libgit2/TestGitRepository" ;
85
+
86
+ SmartSubtransportRegistration < FailingSmartSubtransport > registration = null ;
87
+
88
+ try
89
+ {
90
+ registration = GlobalSettings . RegisterSmartSubtransport < FailingSmartSubtransport > ( "https" ) ;
91
+ Assert . NotNull ( registration ) ;
92
+
93
+ var thrownException = Assert . Throws < LibGit2SharpException > ( ( ) => Repository . Clone ( url , scd . RootedDirectoryPath ) ) ;
94
+ Assert . True ( thrownException . Message . Contains ( "This is a Read Exception" ) , "Exception message did not contain expected reference." ) ;
95
+ }
96
+ finally
97
+ {
98
+ GlobalSettings . UnregisterSmartSubtransport ( registration ) ;
99
+ }
100
+ }
101
+
80
102
//[Theory]
81
103
//[InlineData("https", "https://bitbucket.org/libgit2/testgitrepository.git", "libgit3", "libgit3")]
82
104
//public void CanUseCredentials(string scheme, string url, string user, string pass)
@@ -159,6 +181,32 @@ public void CannotUnregisterTwice()
159
181
GlobalSettings . UnregisterSmartSubtransport ( httpRegistration ) ) ;
160
182
}
161
183
184
+ private class FailingSmartSubtransport : RpcSmartSubtransport
185
+ {
186
+ protected override SmartSubtransportStream Action ( string url , GitSmartSubtransportAction action )
187
+ {
188
+ return new FailingSmartSubtransportStream ( this ) ;
189
+ }
190
+
191
+ private class FailingSmartSubtransportStream : SmartSubtransportStream
192
+ {
193
+ public FailingSmartSubtransportStream ( FailingSmartSubtransport parent )
194
+ : base ( parent )
195
+ {
196
+
197
+ }
198
+ public override int Read ( Stream dataStream , long length , out long bytesRead )
199
+ {
200
+ throw new Exception ( "This is a Read Exception" ) ;
201
+ }
202
+
203
+ public override int Write ( Stream dataStream , long length )
204
+ {
205
+ throw new NotImplementedException ( ) ;
206
+ }
207
+ }
208
+ }
209
+
162
210
private class MockSmartSubtransport : RpcSmartSubtransport
163
211
{
164
212
protected override SmartSubtransportStream Action ( string url , GitSmartSubtransportAction action )
0 commit comments