-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: resolve strictDirectoryName types in mdapi format #601
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -142,6 +142,61 @@ describe('MetadataResolver', () => { | |
expect(access.getComponentsFromPath(path)).to.deep.equal([matchingContentFile.COMPONENT]); | ||
}); | ||
|
||
it('Should determine type for metadata file with known suffix and strictDirectoryName', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I made sure the test failed without the fix. |
||
// CustomSite is an example. The conditions are: | ||
// 1. Type has "strictDirectoryName": true | ||
// 2. Type strategy adapter is neither "mixedContent" nor "bundle" | ||
// 3. Type doesn't have children | ||
// 4. mdapi format file path (E_Bikes.site) | ||
const path = join('unpackaged', 'sites', 'E_Bikes.site'); | ||
const treeContainer = VirtualTreeContainer.fromFilePaths([path]); | ||
const mdResolver = new MetadataResolver(undefined, treeContainer); | ||
const expectedComponent = new SourceComponent( | ||
{ | ||
name: 'E_Bikes', | ||
type: registry.types.customsite, | ||
xml: path, | ||
}, | ||
treeContainer | ||
); | ||
expect(mdResolver.getComponentsFromPath(path)).to.deep.equal([expectedComponent]); | ||
}); | ||
|
||
it('Should determine type for source file with known suffix and strictDirectoryName', () => { | ||
// CustomSite is an example. The conditions are: | ||
// 1. Type has "strictDirectoryName": true | ||
// 2. Type strategy adapter is neither "mixedContent" nor "bundle" | ||
// 3. Type doesn't have children | ||
// 4. source format file path (E_Bikes.site-meta.xml) | ||
const path = join('unpackaged', 'sites', 'E_Bikes.site-meta.xml'); | ||
const treeContainer = VirtualTreeContainer.fromFilePaths([path]); | ||
const mdResolver = new MetadataResolver(undefined, treeContainer); | ||
const expectedComponent = new SourceComponent( | ||
{ | ||
name: 'E_Bikes', | ||
type: registry.types.customsite, | ||
xml: path, | ||
}, | ||
treeContainer | ||
); | ||
expect(mdResolver.getComponentsFromPath(path)).to.deep.equal([expectedComponent]); | ||
}); | ||
|
||
it('Should determine type for EmailServicesFunction metadata file (mdapi format)', () => { | ||
const path = join('unpackaged', 'emailservices', 'MyEmailServices.xml'); | ||
const treeContainer = VirtualTreeContainer.fromFilePaths([path]); | ||
const mdResolver = new MetadataResolver(undefined, treeContainer); | ||
const expectedComponent = new SourceComponent( | ||
{ | ||
name: 'MyEmailServices', | ||
type: registry.types.emailservicesfunction, | ||
xml: path, | ||
}, | ||
treeContainer | ||
); | ||
expect(mdResolver.getComponentsFromPath(path)).to.deep.equal([expectedComponent]); | ||
}); | ||
|
||
it('Should determine type for path of mixed content type', () => { | ||
const path = mixedContentDirectory.MIXED_CONTENT_DIRECTORY_SOURCE_PATHS[1]; | ||
const access = testUtil.createMetadataResolver([ | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that exception is that little punk emailServicesFunction for whom
.xml
is the suffix.now that we're testing with a real registry, can you make sure that it's handled correctly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested manually and added a unit test for it. The fix doesn't affect it since the matching wouldn't get that far with the
EmailServicesFunction
type; it's not defined as"strictDirectoryName": true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, I was wanting it in a strictDir. ESF has a habit of matching way too promiscuously and I'm trying to keep that from happening.
https://github.com/forcedotcom/source-deploy-retrieve/pull/595/files#diff-af7a780a5aa66c4831707c3ccd4e24d4f88a6639346bc0b1897c287efcbe14c9
So...what would happen if it were in strictDir?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing would help us out, but I think it would still work just fine because it would only get to the suffix matching if the path contained the expected directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After testing, ESF still retrieves and deploys successfully when defined as a strictDirectoryName.