@@ -2098,11 +2098,13 @@ mod test {
20982098 . create ( )
20992099 . await ?;
21002100 let web = env. web_app ( ) . await ;
2101- let resp = web
2102- . assert_redirect ( "/dummy" , "/dummy/latest/dummy/" )
2103- . await ?;
2104- assert_eq ! ( resp. status( ) , StatusCode :: FOUND ) ;
2105- assert ! ( resp. headers( ) . get( "Cache-Control" ) . is_none( ) ) ;
2101+ web. assert_redirect_cached (
2102+ "/dummy" ,
2103+ "/dummy/latest/dummy/" ,
2104+ CachePolicy :: ForeverInCdn ,
2105+ env. config ( ) ,
2106+ )
2107+ . await ?;
21062108 Ok ( ( ) )
21072109 } )
21082110 }
@@ -3032,7 +3034,15 @@ mod test {
30323034 #[ test_case( "search-1234.js" ) ]
30333035 #[ test_case( "settings-1234.js" ) ]
30343036 fn fallback_to_root_storage_for_some_js_assets ( path : & str ) {
3035- // test workaround for https://github.com/rust-lang/docs.rs/issues/1979
3037+ // tests for two separate things needed to serve old rustdoc content
3038+ // 1. `/{crate}/{version}/asset.js`, where we try to find the assets in the rustdoc archive
3039+ // 2. `/asset.js` where we try to find it in RUSTDOC_STATIC_STORAGE_PREFIX
3040+ //
3041+ // For 2), new builds use the assets from RUSTDOC_STATIC_STORAGE_PREFIX via
3042+ // `/-/rustdoc.static/asset.js`.
3043+ //
3044+ // For 1) I'm actually not sure, new builds don't seem to have these assets.
3045+ // ( the logic is special-cased to `search-` and `settings-` prefixes.)
30363046 async_wrapper ( |env| async move {
30373047 env. fake_release ( )
30383048 . await
@@ -3042,21 +3052,23 @@ mod test {
30423052 . create ( )
30433053 . await ?;
30443054
3055+ const ROOT_ASSET : & str = "normalize-20200403-1.44.0-nightly-74bd074ee.css" ;
3056+
30453057 let storage = env. async_storage ( ) ;
3046- storage. store_one ( "asset.js" , * b"content" ) . await ?;
3058+ storage. store_one ( ROOT_ASSET , * b"content" ) . await ?;
30473059 storage. store_one ( path, * b"more_content" ) . await ?;
30483060
30493061 let web = env. web_app ( ) . await ;
30503062
3051- let response = web. get ( "/dummy/0.1.0/asset.js" ) . await ?;
3063+ let response = web. get ( & format ! ( "/dummy/0.1.0/{ROOT_ASSET}" ) ) . await ?;
30523064 assert_eq ! (
30533065 response. status( ) ,
30543066 StatusCode :: NOT_FOUND ,
30553067 "{:?}" ,
30563068 response. headers( ) . get( "Location" ) ,
30573069 ) ;
30583070
3059- web. assert_success_and_conditional_get ( "/asset.js" , "content" )
3071+ web. assert_success_and_conditional_get ( & format ! ( "/{ROOT_ASSET}" ) , "content" )
30603072 . await ?;
30613073 web. assert_success_and_conditional_get ( & format ! ( "/dummy/0.1.0/{path}" ) , "more_content" )
30623074 . await ?;
0 commit comments