-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wp-env: granular volume mappings (#22256)
- Loading branch information
1 parent
903e52c
commit 3616a16
Showing
7 changed files
with
250 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
{ | ||
"core": "WordPress/WordPress", | ||
"plugins": [ "." ] | ||
"plugins": [ "." ], | ||
"mappings": { | ||
"wp-content/mu-plugins": "./packages/e2e-tests/mu-plugins", | ||
"wp-content/plugins/gutenberg-test-plugins": "./packages/e2e-tests/plugins" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
const buildDockerComposeConfig = require( '../lib/build-docker-compose-config' ); | ||
|
||
// The basic config keys which build docker compose config requires. | ||
const CONFIG = { | ||
mappings: {}, | ||
pluginSources: [], | ||
themeSources: [], | ||
port: 8888, | ||
testsPort: 8889, | ||
configDirectoryPath: '/path/to/config', | ||
}; | ||
|
||
describe( 'buildDockerComposeConfig', () => { | ||
it( 'should map directories before individual sources', () => { | ||
const envConfig = { | ||
...CONFIG, | ||
mappings: { | ||
'wp-content/plugins': { | ||
path: '/path/to/wp-plugins', | ||
}, | ||
}, | ||
pluginSources: [ | ||
{ path: '/path/to/local/plugin', basename: 'test-name' }, | ||
], | ||
}; | ||
const dockerConfig = buildDockerComposeConfig( envConfig ); | ||
const { volumes } = dockerConfig.services.wordpress; | ||
expect( volumes ).toEqual( [ | ||
'wordpress:/var/www/html', // WordPress root | ||
'/path/to/wp-plugins:/var/www/html/wp-content/plugins', // Mapped plugins root | ||
'/path/to/local/plugin:/var/www/html/wp-content/plugins/test-name', // Mapped plugin | ||
] ); | ||
} ); | ||
|
||
it( 'should add all specified sources to tests, dev, and cli services', () => { | ||
const envConfig = { | ||
...CONFIG, | ||
mappings: { | ||
'wp-content/plugins': { | ||
path: '/path/to/wp-plugins', | ||
}, | ||
}, | ||
pluginSources: [ | ||
{ path: '/path/to/local/plugin', basename: 'test-name' }, | ||
], | ||
themeSources: [ | ||
{ path: '/path/to/local/theme', basename: 'test-theme' }, | ||
], | ||
}; | ||
const dockerConfig = buildDockerComposeConfig( envConfig ); | ||
const devVolumes = dockerConfig.services.wordpress.volumes; | ||
const cliVolumes = dockerConfig.services.cli.volumes; | ||
expect( devVolumes ).toEqual( cliVolumes ); | ||
|
||
const testsVolumes = dockerConfig.services[ 'tests-wordpress' ].volumes; | ||
const testsCliVolumes = dockerConfig.services[ 'tests-cli' ].volumes; | ||
expect( testsVolumes ).toEqual( testsCliVolumes ); | ||
|
||
const localSources = [ | ||
'/path/to/wp-plugins:/var/www/html/wp-content/plugins', | ||
'/path/to/local/plugin:/var/www/html/wp-content/plugins/test-name', | ||
'/path/to/local/theme:/var/www/html/wp-content/themes/test-theme', | ||
]; | ||
|
||
expect( devVolumes ).toEqual( expect.arrayContaining( localSources ) ); | ||
expect( testsVolumes ).toEqual( | ||
expect.arrayContaining( localSources ) | ||
); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters