-
Notifications
You must be signed in to change notification settings - Fork 314
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
Changes from all commits
1402082
e771153
03b904e
b4aa154
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 |
---|---|---|
|
@@ -26,12 +26,12 @@ import io.kotest.core.spec.style.WordSpec | |
import io.kotest.inspectors.forAll | ||
import io.kotest.matchers.shouldBe | ||
|
||
import org.ossreviewtoolkit.model.HashAlgorithm | ||
import org.ossreviewtoolkit.model.VcsInfo | ||
import org.ossreviewtoolkit.model.VcsType | ||
import org.ossreviewtoolkit.model.readJsonTree | ||
|
||
class NpmSupportTest : WordSpec({ | ||
"expandNpmShortcutUrl" should { | ||
"expandNpmShortcutUrl()" should { | ||
"do nothing for empty URLs" { | ||
expandNpmShortcutUrl("") shouldBe "" | ||
} | ||
|
@@ -80,7 +80,7 @@ class NpmSupportTest : WordSpec({ | |
} | ||
} | ||
|
||
"fixNpmDownloadUrl" should { | ||
"fixNpmDownloadUrl()" should { | ||
"replace HTTP with HTTPS for the NPM registry only" { | ||
fixNpmDownloadUrl("http://registry.npmjs.org/babel-cli/-/babel-cli-6.26.0.tgz") shouldBe | ||
"https://registry.npmjs.org/babel-cli/-/babel-cli-6.26.0.tgz" | ||
|
@@ -93,7 +93,7 @@ class NpmSupportTest : WordSpec({ | |
} | ||
} | ||
|
||
"parseNpmAuthors" should { | ||
"parseNpmAuthors()" should { | ||
"get authors from a text node" { | ||
val node = ObjectMapper().run { | ||
createObjectNode().apply { | ||
|
@@ -118,7 +118,7 @@ class NpmSupportTest : WordSpec({ | |
} | ||
} | ||
|
||
"parseNpmLicenses" should { | ||
"parseNpmLicenses()" should { | ||
"get a singular 'license' from a text node" { | ||
val node = ObjectMapper().run { | ||
createObjectNode().apply { | ||
|
@@ -191,30 +191,44 @@ class NpmSupportTest : WordSpec({ | |
} | ||
} | ||
|
||
"parseNpmVcsInfo" should { | ||
"get VCS information from an object node" { | ||
@Suppress("Wrapping") | ||
val node = ObjectMapper().run { | ||
createObjectNode().apply { | ||
replace("gitHead", TextNode(HashAlgorithm.SHA1GIT.emptyValue)) | ||
replace("repository", createObjectNode().apply { | ||
replace("type", TextNode("Git")) | ||
replace("url", TextNode("https://example.com/")) | ||
replace("directory", TextNode("foo")) | ||
}) | ||
"parseNpmVcsInfo()" should { | ||
"get VCS information from an object node containing a repository node which is an object" { | ||
val node = """ | ||
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'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. 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 would do a follow up PR for this 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. here you go: #8518 |
||
{ | ||
"gitHead": "bar", | ||
"repository": { | ||
"type": "Git", | ||
"url": "https://example.com/", | ||
"directory": "foo" | ||
} | ||
} | ||
""".readJsonTree() | ||
|
||
parseNpmVcsInfo(node) shouldBe VcsInfo( | ||
VcsType.GIT, | ||
"https://example.com/", | ||
HashAlgorithm.SHA1GIT.emptyValue, | ||
"bar", | ||
"foo" | ||
) | ||
} | ||
|
||
"get VCS information from an object node containing a repository node which is textual" { | ||
val node = """ | ||
{ | ||
"gitHead": "bar", | ||
"repository": "git+ssh://example.com/a/b.git" | ||
} | ||
""".readJsonTree() | ||
|
||
parseNpmVcsInfo(node) shouldBe VcsInfo( | ||
VcsType.UNKNOWN, | ||
"git+ssh://example.com/a/b.git", | ||
"bar" | ||
) | ||
} | ||
} | ||
|
||
"splitNpmNamespaceAndName" should { | ||
"splitNpmNamespaceAndName()" should { | ||
"return the namespace and name separately" { | ||
splitNpmNamespaceAndName("@babel/core") shouldBe Pair("@babel", "core") | ||
splitNpmNamespaceAndName("check-if-windows") shouldBe Pair("", "check-if-windows") | ||
|
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.
Commit message: s/programatical/programatic/