Skip to content

Commit

Permalink
test(fanal): add test to check latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriyLewen committed Jul 26, 2024
1 parent 160ab40 commit eb0ca05
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"dependencies": {
"debug": "latest"
},
"devDependencies" : {
"js-tokens": "^9.0.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


debug@latest:
version "4.3.5"
resolved "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz"
integrity sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==
dependencies:
ms "2.1.2"

js-tokens@^9.0.0:
version "9.0.0"
resolved "https://registry.npmjs.org/js-tokens/-/js-tokens-9.0.0.tgz"
integrity sha512-WriZw1luRMlmV3LGJaR6QOJjWwgLUTf89OwT2lUOyjX2dJGBwgmIkbcz+7WFZjrZM635JOIR517++e/67CP9dQ==

[email protected]:
version "2.1.2"
resolved "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz"
integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==
55 changes: 55 additions & 0 deletions pkg/fanal/analyzer/language/nodejs/yarn/yarn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,61 @@ func Test_yarnLibraryAnalyzer_Analyze(t *testing.T) {
},
},
},
{
name: "package uses `latest` version",
dir: "testdata/latest-version",
want: &analyzer.AnalysisResult{
Applications: []types.Application{
{
Type: types.Yarn,
FilePath: "yarn.lock",
Packages: types.Packages{
{
ID: "[email protected]",
Name: "debug",
Version: "4.3.5",
Relationship: types.RelationshipDirect,
Locations: []types.Location{
{
StartLine: 5,
EndLine: 10,
},
},
DependsOn: []string{
"[email protected]",
},
},
{
ID: "[email protected]",
Name: "js-tokens",
Version: "9.0.0",
Relationship: types.RelationshipDirect,
Dev: true,
Locations: []types.Location{
{
StartLine: 12,
EndLine: 15,
},
},
},
{
ID: "[email protected]",
Name: "ms",
Version: "2.1.2",
Indirect: true,
Relationship: types.RelationshipIndirect,
Locations: []types.Location{
{
StartLine: 17,
EndLine: 20,
},
},
},
},
},
},
},
},
{
name: "happy path with alias rewrite",
dir: "testdata/alias",
Expand Down

0 comments on commit eb0ca05

Please sign in to comment.