@@ -7,6 +7,7 @@ import execa from 'execa'
7
7
import fetch from 'node-fetch'
8
8
import { afterAll , beforeAll , describe , expect , test } from 'vitest'
9
9
10
+ import { getToken } from '../../../../src/utils/command-helpers.ts'
10
11
import { callCli } from '../../utils/call-cli.js'
11
12
import { createLiveTestSite , generateSiteName } from '../../utils/create-live-test-site.js'
12
13
import { FixtureTestContext , setupFixtureTests } from '../../utils/fixture.js'
@@ -953,6 +954,71 @@ describe.skipIf(process.env.NETLIFY_TEST_DISABLE_LIVE === 'true').concurrent('co
953
954
} )
954
955
} )
955
956
957
+ test . only ( 'should upload blobs when saved into .netlify directory and using --auth flag' , async ( t ) => {
958
+ await withSiteBuilder ( t , async ( builder ) => {
959
+ await builder
960
+ . withNetlifyToml ( {
961
+ config : {
962
+ build : { functions : 'functions' , publish : 'dist' } ,
963
+ } ,
964
+ } )
965
+ . withContentFile ( {
966
+ path : 'dist/index.html' ,
967
+ content : '<a href="/read-blob">get blob</a>' ,
968
+ } )
969
+ . withContentFile ( {
970
+ path : '.netlify/blobs/deploy/hello' ,
971
+ content : 'hello from the blob' ,
972
+ } )
973
+ . withPackageJson ( {
974
+ packageJson : {
975
+ dependencies : {
976
+ '@netlify/blobs' : '^6.3.0' ,
977
+ '@netlify/functions' : '^2.4.0' ,
978
+ } ,
979
+ } ,
980
+ } )
981
+ . withContentFile ( {
982
+ path : 'functions/read-blob.ts' ,
983
+ content : `
984
+ import { getDeployStore } from "@netlify/blobs"
985
+ import { Config } from "@netlify/functions"
986
+
987
+ export default async () => {
988
+ const store = getDeployStore()
989
+ const blob = await store.get('hello')
990
+
991
+ return new Response(blob)
992
+ }
993
+
994
+ export const config: Config = {
995
+ path: "/read-blob"
996
+ }
997
+ ` ,
998
+ } )
999
+ . build ( )
1000
+
1001
+ const [ authToken ] = await getToken ( '' )
1002
+
1003
+ if ( ! authToken ) {
1004
+ throw new Error ( 'Failed to get current auth token' )
1005
+ }
1006
+
1007
+ await execa . command ( 'npm install' , { cwd : builder . directory } )
1008
+ const { deploy_url : deployUrl } = await callCli (
1009
+ [ 'deploy' , '--json' , '--auth' , authToken ] ,
1010
+ {
1011
+ cwd : builder . directory ,
1012
+ env : { NETLIFY_SITE_ID : context . siteId , NETLIFY_AUTH_TOKEN : '' } ,
1013
+ } ,
1014
+ true ,
1015
+ )
1016
+
1017
+ const response = await fetch ( `${ deployUrl } /read-blob` ) . then ( ( res ) => res . text ( ) )
1018
+ t . expect ( response ) . toEqual ( 'hello from the blob' )
1019
+ } )
1020
+ } )
1021
+
956
1022
setupFixtureTests ( 'next-app-without-config' , ( ) => {
957
1023
test < FixtureTestContext > (
958
1024
'should run deploy with --build without any netlify specific configuration' ,
0 commit comments