Skip to content

Commit

Permalink
chore: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
florian-lefebvre committed Aug 12, 2024
1 parent 18978c7 commit d835645
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 41 deletions.
6 changes: 2 additions & 4 deletions packages/astro/test/env-secret.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,8 @@ describe('astro:env secret variables', () => {
it('fails if validateSecrets is enabled and secret is not set', async () => {
fixture = await loadFixture({
root: './fixtures/astro-env-server-secret/',
experimental: {
env: {
validateSecrets: true,
},
env: {
validateSecrets: true,
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ import { defineConfig, envField } from 'astro/config';

// https://astro.build/config
export default defineConfig({
experimental: {
env: {
schema: {
FOO: envField.string({ context: "client", access: "public" }),
BAR: envField.number({ context: "server", access: "public" }),
}
env: {
schema: {
FOO: envField.string({ context: "client", access: "public" }),
BAR: envField.number({ context: "server", access: "public" }),
}
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ import { defineConfig, envField } from 'astro/config';

// https://astro.build/config
export default defineConfig({
experimental: {
env: {
schema: {
FOO: envField.string({ context: "server", access: "public", optional: true, default: "ABC" }),
}
env: {
schema: {
FOO: envField.string({ context: "server", access: "public", optional: true, default: "ABC" }),
}
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ import { defineConfig, envField } from 'astro/config';

// https://astro.build/config
export default defineConfig({
experimental: {
env: {
schema: {
KNOWN_SECRET: envField.number({ context: "server", access: "secret" })
}
env: {
schema: {
KNOWN_SECRET: envField.number({ context: "server", access: "secret" })
}
}
});
12 changes: 5 additions & 7 deletions packages/astro/test/fixtures/astro-env/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ import { defineConfig, envField } from 'astro/config';

// https://astro.build/config
export default defineConfig({
experimental: {
env: {
schema: {
FOO: envField.string({ context: "client", access: "public", optional: true, default: "ABC" }),
BAR: envField.string({ context: "client", access: "public", optional: true, default: "DEF" }),
BAZ: envField.string({ context: "server", access: "public", optional: true, default: "GHI" }),
}
env: {
schema: {
FOO: envField.string({ context: "client", access: "public", optional: true, default: "ABC" }),
BAR: envField.string({ context: "client", access: "public", optional: true, default: "DEF" }),
BAZ: envField.string({ context: "server", access: "public", optional: true, default: "GHI" }),
}
}
});
22 changes: 8 additions & 14 deletions packages/astro/test/units/config/config-validate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,8 @@ describe('Config Validation', () => {
assert.doesNotThrow(() =>
validateConfig(
{
experimental: {
env: {
schema: undefined,
},
env: {
schema: undefined,
},
},
process.cwd(),
Expand All @@ -373,11 +371,9 @@ describe('Config Validation', () => {
assert.doesNotThrow(() =>
validateConfig(
{
experimental: {
env: {
schema: {
ABC123: envField.string({ access: 'public', context: 'server' }),
},
env: {
schema: {
ABC123: envField.string({ access: 'public', context: 'server' }),
},
},
},
Expand All @@ -389,11 +385,9 @@ describe('Config Validation', () => {
it('Should not allow schema variables starting with a number', async () => {
const configError = await validateConfig(
{
experimental: {
env: {
schema: {
'123ABC': envField.string({ access: 'public', context: 'server' }),
},
env: {
schema: {
'123ABC': envField.string({ access: 'public', context: 'server' }),
},
},
},
Expand Down

0 comments on commit d835645

Please sign in to comment.