@@ -481,6 +481,7 @@ describe("--x-provision", () => {
481481 ) ;
482482 } )
483483 ) ;
484+ mockGetD1Database ( "prefilled-d1-name" , { } , true ) ;
484485
485486 // no name prompt
486487 mockCreateD1Database ( {
@@ -597,6 +598,7 @@ describe("--x-provision", () => {
597598 ) ;
598599 } )
599600 ) ;
601+ mockGetD1Database ( "new-d1-name" , { } , true ) ;
600602
601603 mockGetD1Database ( "old-d1-id" , { name : "old-d1-name" } ) ;
602604
@@ -784,18 +786,10 @@ describe("--x-provision", () => {
784786 } ) ;
785787 mockGetSettings ( ) ;
786788
787- msw . use (
788- http . get ( "*/accounts/:accountId/d1/database" , async ( ) => {
789- return HttpResponse . json (
790- createFetchResult ( [
791- {
792- name : "existing-db-name" ,
793- uuid : "existing-d1-id" ,
794- } ,
795- ] )
796- ) ;
797- } )
798- ) ;
789+ mockGetD1Database ( "existing-db-name" , {
790+ name : "existing-db-name" ,
791+ uuid : "existing-d1-id" ,
792+ } ) ;
799793
800794 mockUploadWorkerRequest ( {
801795 expectedBindings : [
@@ -1030,14 +1024,22 @@ function mockGetR2Bucket(bucketName: string, missing: boolean = false) {
10301024}
10311025
10321026function mockGetD1Database (
1033- databaseId : string ,
1034- databaseInfo : Partial < DatabaseInfo >
1027+ databaseIdOrName : string ,
1028+ databaseInfo : Partial < DatabaseInfo > ,
1029+ missing : boolean = false
10351030) {
10361031 msw . use (
10371032 http . get (
10381033 `*/accounts/:accountId/d1/database/:database_id` ,
10391034 ( { params } ) => {
1040- expect ( params . database_id ) . toEqual ( databaseId ) ;
1035+ expect ( params . database_id ) . toEqual ( databaseIdOrName ) ;
1036+ if ( missing ) {
1037+ return HttpResponse . json (
1038+ createFetchResult ( null , false , [
1039+ { code : 7404 , message : "database not found" } ,
1040+ ] )
1041+ ) ;
1042+ }
10411043 return HttpResponse . json ( createFetchResult ( databaseInfo ) ) ;
10421044 } ,
10431045 { once : true }
0 commit comments