@@ -19,6 +19,8 @@ pub(crate) struct FakeRelease<'a> {
19
19
registry_crate_data : RegistryCrateData ,
20
20
has_docs : bool ,
21
21
has_examples : bool ,
22
+ /// This stores the content, while `package.readme` stores the filename
23
+ readme : Option < & ' a str > ,
22
24
}
23
25
24
26
impl < ' a > FakeRelease < ' a > {
@@ -62,6 +64,7 @@ impl<'a> FakeRelease<'a> {
62
64
} ,
63
65
has_docs : true ,
64
66
has_examples : false ,
67
+ readme : None ,
65
68
}
66
69
}
67
70
@@ -92,7 +95,7 @@ impl<'a> FakeRelease<'a> {
92
95
self
93
96
}
94
97
95
- pub fn author ( mut self , author : & str ) -> Self {
98
+ pub ( crate ) fn author ( mut self , author : & str ) -> Self {
96
99
self . package . authors = vec ! [ author. into( ) ] ;
97
100
self
98
101
}
@@ -153,6 +156,12 @@ impl<'a> FakeRelease<'a> {
153
156
self
154
157
}
155
158
159
+ /// NOTE: this should be markdown. It will be rendered as HTML when served.
160
+ pub ( crate ) fn readme ( mut self , content : & ' a str ) -> Self {
161
+ self . readme = Some ( content) ;
162
+ self . source_file ( "README.md" , content. as_bytes ( ) )
163
+ }
164
+
156
165
/// Returns the release_id
157
166
pub ( crate ) fn create ( self ) -> Result < i32 , Error > {
158
167
use std:: collections:: HashSet ;
@@ -223,10 +232,14 @@ impl<'a> FakeRelease<'a> {
223
232
}
224
233
}
225
234
235
+ let crate_dir = tempdir. path ( ) ;
236
+ if let Some ( markdown) = self . readme {
237
+ fs:: write ( crate_dir. join ( "README.md" ) , markdown) ?;
238
+ }
226
239
let release_id = crate :: db:: add_package_into_database (
227
240
& db. conn ( ) ,
228
241
& package,
229
- tempdir . path ( ) ,
242
+ crate_dir ,
230
243
& self . build_result ,
231
244
self . default_target . unwrap_or ( "x86_64-unknown-linux-gnu" ) ,
232
245
source_meta,
0 commit comments