Skip to content

Commit 4fcd76d

Browse files
committed
test: add deploy test for --auth and blobs uploads
1 parent 6a97ea2 commit 4fcd76d

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

tests/integration/commands/deploy/deploy.test.ts

+66
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import execa from 'execa'
77
import fetch from 'node-fetch'
88
import { afterAll, beforeAll, describe, expect, test } from 'vitest'
99

10+
import { getToken } from '../../../../src/utils/command-helpers.ts'
1011
import { callCli } from '../../utils/call-cli.js'
1112
import { createLiveTestSite, generateSiteName } from '../../utils/create-live-test-site.js'
1213
import { FixtureTestContext, setupFixtureTests } from '../../utils/fixture.js'
@@ -953,6 +954,71 @@ describe.skipIf(process.env.NETLIFY_TEST_DISABLE_LIVE === 'true').concurrent('co
953954
})
954955
})
955956

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+
9561022
setupFixtureTests('next-app-without-config', () => {
9571023
test<FixtureTestContext>(
9581024
'should run deploy with --build without any netlify specific configuration',

0 commit comments

Comments
 (0)