11import { getBindingsProxy } from 'wrangler' ;
2- import { readFile } from 'fs/promises' ;
3- import path from 'path' ;
42import { drizzle } from 'drizzle-orm/d1' ;
53import app , { type Bindings } from './index' ;
64import * as models from './models' ;
@@ -11,11 +9,11 @@ const { bindings } = await getBindingsProxy();
119const appEnv : Bindings = {
1210 DB : bindings . DB as D1Database ,
1311 VH7_ENV : 'testing' ,
14- S3_ACCESS_KEY_ID : 'minioadmin' ,
15- S3_SECRET_ACCESS_KEY : 'minioadmin' ,
16- S3_REGION : 'eu-west-1' ,
17- S3_ENDPOINT_URL : 'http://localhost:9000' ,
18- S3_BUCKET : 'vh7-uploads' ,
12+ S3_ACCESS_KEY_ID : process . env . S3_ACCESS_KEY_ID || 'minioadmin' ,
13+ S3_SECRET_ACCESS_KEY : process . env . S3_SECRET_ACCESS_KEY || 'minioadmin' ,
14+ S3_REGION : process . env . S3_REGION || 'eu-west-1' ,
15+ S3_ENDPOINT_URL : process . env . S3_ENDPOINT_URL || 'http://localhost:9000' ,
16+ S3_BUCKET : process . env . S3_BUCKET || 'vh7-uploads' ,
1917} ;
2018
2119beforeAll ( async ( ) => {
@@ -117,9 +115,10 @@ describe('API', () => {
117115 } ) ;
118116
119117 test ( 'upload' , async ( ) => {
120- const filename = path . join ( __dirname , '../../app/public/assets/favicon.ico' ) ;
121118 const data = new FormData ( ) ;
122- data . append ( 'file' , new Blob ( [ await readFile ( filename ) ] ) , 'favicon.ico' ) ;
119+ data . append ( 'file' , new Blob ( [ 'Hello, World!' ] , {
120+ type : 'text/plain' ,
121+ } ) , 'test.txt' ) ;
123122
124123 const res = await app . request ( 'http://vh7.uk/api/upload' , {
125124 method : 'POST' ,
@@ -132,9 +131,9 @@ describe('API', () => {
132131 expect . objectContaining ( {
133132 id : expect . any ( String ) ,
134133 type : 'upload' ,
135- filename : 'favicon.ico ' ,
136- size : 15406 ,
137- hash : 'b8eea8c82be6c275d8f664b5cafc5b5081e240e4f1826aa57f068606a1c8741f ' ,
134+ filename : 'test.txt ' ,
135+ size : 13 ,
136+ hash : 'dffd6021bb2bd5b0af676290809ec3a53191dd81c7f70a4b28688a362182986f ' ,
138137 createdAt : expect . any ( String ) ,
139138 expiresAt : expect . any ( String ) ,
140139 updatedAt : expect . any ( String ) ,
0 commit comments