-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(fanal): add test to check latest version
- Loading branch information
1 parent
160ab40
commit eb0ca05
Showing
3 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
pkg/fanal/analyzer/language/nodejs/yarn/testdata/latest-version/package.json
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"dependencies": { | ||
"debug": "latest" | ||
}, | ||
"devDependencies" : { | ||
"js-tokens": "^9.0.0" | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
pkg/fanal/analyzer/language/nodejs/yarn/testdata/latest-version/yarn.lock
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 |
---|---|---|
@@ -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== |
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 |
---|---|---|
|
@@ -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", | ||
|