-
Notifications
You must be signed in to change notification settings - Fork 166
Add a precondition for declaring a node as beta. #1055
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
Changes from 1 commit
086aae2
46fd65d
fa33727
ea6ceac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1922,6 +1922,22 @@ Document | |
| XCTAssertEqual(renderNode.metadata.platforms?.first?.isBeta, false) | ||
| } | ||
|
|
||
| // Symbol with an empty set of availbility items. | ||
|
|
||
| do { | ||
|
|
||
| let (bundle, context, _) = try makeTestBundle(currentPlatforms: [ | ||
| "Custom Name": PlatformVersion(VersionTriplet(100, 0, 0), beta: true) | ||
| ]) | ||
| let reference = ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/documentation/MyKit/MyClass", sourceLanguage: .swift) | ||
sofiaromorales marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| let node = try context.entity(with: reference) | ||
| (node.semantic as? Symbol)?.availability = SymbolGraph.Symbol.Availability(availability: []) | ||
|
Contributor
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. This is not a blocking comment but something to keep in mind. Modifying a page after the context has fully registered the data provider assumes that there are no derivatives of the original value elsewhere that was created while the context registered the data provider. This means that the test could be exercising a different behavior than a real build would and could pass even though a real build would have a bug. I think that there are no derivates of the availability information today, but there could be in the future in which case this test could hide a bug because it passes and there's no other test that exercises the real-build behavior. Because of this, it's preferred to modify the inputs before they're registered with the context.
Contributor
Author
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. It's true that data could be modified after the fact, but although this generally shouldn't be done, having this precondition adds an extra layer of security to the code. |
||
| let documentationContentRendered = DocumentationContentRenderer(documentationContext: context, bundle: bundle) | ||
| let isBeta = documentationContentRendered.isBeta(node) | ||
| // Verify that the symbol is not beta since it does not contains availability info. | ||
| XCTAssertFalse(isBeta) | ||
| } | ||
|
|
||
| // Different platform is beta | ||
| do { | ||
| let (bundle, context, reference) = try makeTestBundle(currentPlatforms: [ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.