@@ -2147,6 +2147,77 @@ async fn npm_specifier() {
21472147 ) ;
21482148}
21492149
2150+ #[ tokio:: test]
2151+ async fn transform_uses_lockfile_remote_checksum ( ) {
2152+ // a deno.lock with a non-matching remote checksum should cause an
2153+ // integrity error, proving the lockfile is being used
2154+ let result = TestBuilder :: new ( )
2155+ . with_loader ( |loader| {
2156+ loader
2157+ . add_local_file ( "/deno.json" , "{}" )
2158+ . add_local_file (
2159+ "/deno.lock" ,
2160+ concat ! (
2161+ "{\n " ,
2162+ " \" version\" : \" 5\" ,\n " ,
2163+ " \" remote\" : {\n " ,
2164+ " \" https://localhost/mod.ts\" : \" 0000000000000000000000000000000000000000000000000000000000000000\" \n " ,
2165+ " }\n " ,
2166+ "}\n "
2167+ ) ,
2168+ )
2169+ . add_local_file ( "/mod.ts" , "import 'https://localhost/mod.ts';" )
2170+ . add_remote_file ( "https://localhost/mod.ts" , "console.log(1);" ) ;
2171+ } )
2172+ . transform ( )
2173+ . await
2174+ . err ( )
2175+ . unwrap ( ) ;
2176+
2177+ assert ! (
2178+ result
2179+ . to_string( )
2180+ . to_lowercase( )
2181+ . contains( "integrity check failed" ) ,
2182+ "unexpected error: {:#}" ,
2183+ result
2184+ ) ;
2185+ }
2186+
2187+ #[ tokio:: test]
2188+ async fn transform_uses_lockfile_matching_remote_checksum ( ) {
2189+ // a deno.lock with a matching remote checksum should transform successfully
2190+ let result = TestBuilder :: new ( )
2191+ . with_loader ( |loader| {
2192+ loader
2193+ . add_local_file ( "/deno.json" , "{}" )
2194+ . add_local_file (
2195+ "/deno.lock" ,
2196+ concat ! (
2197+ "{\n " ,
2198+ " \" version\" : \" 5\" ,\n " ,
2199+ " \" remote\" : {\n " ,
2200+ " \" https://localhost/mod.ts\" : \" 35c146f76e129477c64061bc84511e1090f3d4d8059713e6663dd4b35b1f7642\" \n " ,
2201+ " }\n " ,
2202+ "}\n "
2203+ ) ,
2204+ )
2205+ . add_local_file ( "/mod.ts" , "import 'https://localhost/mod.ts';" )
2206+ . add_remote_file ( "https://localhost/mod.ts" , "console.log(1);" ) ;
2207+ } )
2208+ . transform ( )
2209+ . await
2210+ . unwrap ( ) ;
2211+
2212+ assert_files ! (
2213+ result. main. files,
2214+ & [
2215+ ( "mod.ts" , "import './deps/localhost/mod.js';" ) ,
2216+ ( "deps/localhost/mod.ts" , "console.log(1);" ) ,
2217+ ]
2218+ ) ;
2219+ }
2220+
21502221fn get_shim_file_text ( mut text : String ) -> String {
21512222 text. push ( '\n' ) ;
21522223 text. push_str (
0 commit comments