@@ -2,11 +2,13 @@ import * as NodeServices from "@effect/platform-node/NodeServices";
22import { ThreadId } from "@t3tools/contracts" ;
33import { PROJECT_FAVICON_FALLBACK_MARKER } from "@t3tools/shared/projectFavicon" ;
44import { describe , expect , it } from "@effect/vitest" ;
5+ import * as Crypto from "effect/Crypto" ;
56import * as Effect from "effect/Effect" ;
67import * as FileSystem from "effect/FileSystem" ;
78import * as Layer from "effect/Layer" ;
89import * as Path from "effect/Path" ;
910import * as PlatformError from "effect/PlatformError" ;
11+ import * as TestClock from "effect/testing/TestClock" ;
1012
1113import * as ServerSecretStore from "../auth/ServerSecretStore.ts" ;
1214import * as ServerConfig from "../config.ts" ;
@@ -262,6 +264,31 @@ describe("AssetAccess", () => {
262264 } ) . pipe ( Effect . provide ( testLayer ) ) ,
263265 ) ;
264266
267+ it . effect ( "buckets project favicon expiry after content hashing" , ( ) =>
268+ Effect . gen ( function * ( ) {
269+ const crypto = yield * Crypto . Crypto ;
270+ const fileSystem = yield * FileSystem . FileSystem ;
271+ const path = yield * Path . Path ;
272+ const root = yield * fileSystem . makeTempDirectoryScoped ( {
273+ prefix : "t3-asset-favicon-expiry-" ,
274+ } ) ;
275+ yield * fileSystem . writeFileString ( path . join ( root , "favicon.svg" ) , "<svg />" ) ;
276+
277+ const bucketMs = 30 * 60 * 1000 ;
278+ yield * TestClock . setTime ( bucketMs - 1 ) ;
279+ const crossingCrypto = Crypto . make ( {
280+ randomBytes : ( size ) => new Uint8Array ( size ) ,
281+ digest : ( algorithm , data ) =>
282+ TestClock . adjust ( "2 millis" ) . pipe ( Effect . andThen ( crypto . digest ( algorithm , data ) ) ) ,
283+ } ) ;
284+ const result = yield * issueAssetUrl ( {
285+ resource : { _tag : "project-favicon" , cwd : root } ,
286+ } ) . pipe ( Effect . provideService ( Crypto . Crypto , crossingCrypto ) ) ;
287+
288+ expect ( result . expiresAt ) . toBe ( 3 * bucketMs ) ;
289+ } ) . pipe ( Effect . provide ( testLayer ) ) ,
290+ ) ;
291+
265292 it . effect ( "preserves structured project favicon resolution causes" , ( ) =>
266293 Effect . gen ( function * ( ) {
267294 const fileSystem = yield * FileSystem . FileSystem ;
0 commit comments