Skip to content
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

test(node): Cover textual repository nodes #8512

Merged
merged 4 commits into from
Apr 12, 2024

Conversation

fviernau
Copy link
Member

See individual commits.

@fviernau fviernau requested a review from a team as a code owner April 12, 2024 11:51
@fviernau fviernau force-pushed the npm-handle-textual-repository-nodes branch from e6dba7e to cb39f8c Compare April 12, 2024 11:55
@@ -196,7 +195,7 @@ class NpmSupportTest : WordSpec({
@Suppress("Wrapping")
val node = ObjectMapper().run {
createObjectNode().apply {
replace("gitHead", TextNode(HashAlgorithm.SHA1GIT.emptyValue))
replace("gitHead", TextNode("bar"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit message: This is not about the "VCS path", but the "VCS revision".

@@ -73,3 +73,5 @@ val EMPTY_JSON_NODE: JsonNode = MissingNode.getInstance()
inline fun <reified T> String.fromYaml(): T = yamlMapper.readValue(this)

fun Any?.toYaml(): String = yamlMapper.writeValueAsString(this)

fun String.readJsonTree(): JsonNode = jsonMapper.readTree(this)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit message: s/programatical/programatic/

replace("url", TextNode("https://example.com/"))
replace("directory", TextNode("foo"))
})
val node = """
Copy link
Member

@sschuberth sschuberth Apr 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be some work, but I guess ideally this should be done for all tests in this file now, or? That would nicely decouple the test from Jackson as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would do a follow up PR for this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here you go: #8518

)
} else {
val type = repository["type"].textValueOrEmpty()
val url = repository.textValue() ?: repository["url"].textValueOrEmpty()
Copy link
Member

@sschuberth sschuberth Apr 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the original repository.textValue() here already handles the repository.isTextual case, or?

At least I'm pretty sure that the original code already intended to fully handle that case:

  • type would be empty, so VcsType.forName(type) returns VcsType.UNKNOWN
  • path would be empty as well

So what additional case does your new code cover?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HM, are you sure that the previous code already worked in this case?

When I wrote this code (in my other PR) I do re-call that the analyzer previously did not detect VCS info but afterwards did. So, thought it was needed but probably I made a mistake during testing and had made further changes which made it work.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test proofs that you were right.

Do not use the constant for the empty value as this can be misleading
one into thinking there may be special handling for that. So, use an
arbitrary string as for the VCS revision.

Signed-off-by: Frank Viernau <[email protected]>
Use a JSON string instead of programatic construction of the JSON
object.

Signed-off-by: Frank Viernau <[email protected]>
The repository nodes can be textual, see [1]. Add a test to clarify
the parsing works for that.

[1]: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#repository

Signed-off-by: Frank Viernau <[email protected]>
@fviernau fviernau force-pushed the npm-handle-textual-repository-nodes branch from cb39f8c to b4aa154 Compare April 12, 2024 16:53
@fviernau fviernau changed the title feat(node): Handle textual repository nodes test(node): Cover textual repository nodes Apr 12, 2024
@fviernau fviernau merged commit dde0365 into main Apr 12, 2024
20 of 21 checks passed
@fviernau fviernau deleted the npm-handle-textual-repository-nodes branch April 12, 2024 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants