Skip to content

Commit

Permalink
test: don't run edge handlers deploy if account doesn't support it (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
erezrokah authored Nov 11, 2020
1 parent e13c9c6 commit 3cf539a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/command.addons.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const siteName = generateSiteName('netlify-test-addons-')

if (process.env.IS_FORK !== 'true') {
test.before(async (t) => {
const siteId = await createLiveTestSite(siteName)
const { siteId } = await createLiveTestSite(siteName)
const builder = createSiteBuilder({ siteName: 'site-with-addons' })
await builder.buildAsync()

Expand Down
12 changes: 11 additions & 1 deletion tests/command.deploy.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const process = require('process')

const test = require('ava')
const dotProp = require('dot-prop')
const fetch = require('node-fetch')
const omit = require('omit.js').default

Expand Down Expand Up @@ -37,8 +38,9 @@ const validateDeploy = async ({ deploy, siteName, content, t }) => {

if (process.env.IS_FORK !== 'true') {
test.before(async (t) => {
const siteId = await createLiveTestSite(SITE_NAME)
const { siteId, account } = await createLiveTestSite(SITE_NAME)
t.context.siteId = siteId
t.context.account = account
})

test.serial('should deploy site when dir flag is passed', async (t) => {
Expand Down Expand Up @@ -91,6 +93,14 @@ if (process.env.IS_FORK !== 'true') {
const EDGE_HANDLER_MIN_LENGTH = 50
if (version >= EDGE_HANDLER_MIN_VERSION) {
test.serial('should deploy edge handlers when directory exists', async (t) => {
const {
context: { account },
} = t
const supportsEdgeHandlers = dotProp.get(account, 'capabilities.edge_handlers.included')
if (!supportsEdgeHandlers) {
console.warn(`Skipping edge handlers deploy test for account ${account.slug}`)
return
}
await withSiteBuilder('site-with-public-folder', async (builder) => {
const content = '<h1>⊂◉‿◉つ</h1>'
builder
Expand Down
2 changes: 1 addition & 1 deletion tests/command.env.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const getArgsFromState = function (state) {

if (process.env.IS_FORK !== 'true') {
test.before(async (t) => {
const siteId = await createLiveTestSite(siteName)
const { siteId } = await createLiveTestSite(siteName)
const builder = createSiteBuilder({ siteName: 'site-with-env-vars' })
.withEnvFile({
path: ENV_FILE_NAME,
Expand Down
5 changes: 3 additions & 2 deletions tests/utils/create-live-test-site.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ const createLiveTestSite = async function (siteName) {
if (!Array.isArray(accounts) || accounts.length <= 0) {
throw new Error(`Can't find suitable account to create a site`)
}
const accountSlug = accounts[0].slug
const [account] = accounts
const accountSlug = account.slug
console.log(`Using account ${accountSlug} to create site: ${siteName}`)
const cliResponse = await callCli(['sites:create', '--name', siteName, '--account-slug', accountSlug])

Expand All @@ -36,7 +37,7 @@ const createLiveTestSite = async function (siteName) {
if (matches && Object.prototype.hasOwnProperty.call(matches, 1) && matches[1]) {
const [, siteId] = matches
console.log(`Done creating site ${siteName} for account '${accountSlug}'. Site Id: ${siteId}`)
return siteId
return { siteId, account }
}

throw new Error(`Failed creating site: ${cliResponse}`)
Expand Down

0 comments on commit 3cf539a

Please sign in to comment.