Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions integration/cli/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "cli-it",
"version": "0.0.1",
"description": "crda-javascript-api cli integration tests",
"private": true,
"type": "module",
"license": "Apache-2.0",
"dependencies": {
"@RHEcosystemAppEng/crda-javascript-api": "file:../../"
}
}
14 changes: 14 additions & 0 deletions integration/expected_stack_json_summary
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"dependencies": {
"scanned": 1,
"transitive": 0
},
"vulnerabilities": {
"total": 7,
"direct": 1,
"critical": 1,
"high": 3,
"medium": 2,
"low": 1
}
}
56 changes: 33 additions & 23 deletions integration/run_it.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
#!/usr/bin/env bash

# utility function takes file name and a command
# used for matching the file content and the command output
match() {
if [[ $(< "$1") != "$(eval "$2")" ]]; then
echo "- FAILED"
exit 1
fi
echo "- PASSED"
}

##########################################
###### Verify Required Tools Exists ######
##########################################
Expand Down Expand Up @@ -29,20 +39,10 @@ fi
echo "- SUCCESSFUL"

echo "RUNNING JavaScript integration test for Stack Analysis report in Html"
htmlStackRep=$(node javascript/index.js stack pom.xml true)
if [[ $(< expected_stack_html) != "$htmlStackRep" ]]; then
echo "- FAILED"
exit 1
fi
echo "- PASSED"
match "expected_stack_html" "node javascript/index.js stack pom.xml true"

echo "RUNNING JavaScript integration test for Stack Analysis report in Json"
jsonStackRep=$(node javascript/index.js stack pom.xml false)
if [[ $(< expected_stack_json) != "$jsonStackRep" ]]; then
echo "- FAILED"
exit 1
fi
echo "- PASSED"
match "expected_stack_json" "node javascript/index.js stack pom.xml false"

##########################################
###### TypeScript Integration Tests ######
Expand All @@ -62,17 +62,27 @@ then
fi

echo "RUNNING TypeScript integration test for Stack Analysis report in Html"
htmlStackRep=$(node typescript/dist/index.js stack pom.xml true)
if [[ $(< expected_stack_html) != "$htmlStackRep" ]]; then
echo "- FAILED"
exit 1
fi
echo "- PASSED"
match "expected_stack_html" "node typescript/dist/index.js stack pom.xml true"

echo "RUNNING TypeScript integration test for Stack Analysis report in Json"
jsonStackRep=$(node typescript/dist/index.js stack pom.xml false)
if [[ $(< expected_stack_json) != "$jsonStackRep" ]]; then
echo "- FAILED"
exit 1
match "expected_stack_json" "node typescript/dist/index.js stack pom.xml false"

##########################################
###### CMD Script Integration Tests ######
##########################################
echo "PREPARING CLI Script integration tests environment"
if ! npm --prefix cli install --force --silent
then
echo "- FAILED Installing modules for JS environment"
exit $?
fi
echo "- PASSED"
echo "- SUCCESSFUL"

echo "RUNNING CLI Script integration test for Stack Analysis report in Html"
match "expected_stack_html" "node cli/node_modules/@RHEcosystemAppEng/crda-javascript-api/dist/src/cli.js stack pom.xml --html"

echo "RUNNING CLI Script integration test for Stack Analysis report in full Json"
match "expected_stack_json" "node cli/node_modules/@RHEcosystemAppEng/crda-javascript-api/dist/src/cli.js stack pom.xml"

echo "RUNNING CLI Script integration test for Stack Analysis report in full Json"
match "expected_stack_json_summary" "node cli/node_modules/@RHEcosystemAppEng/crda-javascript-api/dist/src/cli.js stack pom.xml --summary"
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"npm": ">= 9.0.0"
},
"type": "module",
"bin": "dist/src/cmd.js",
"bin": "dist/src/cli.js",
"main": "dist/src/index.js",
"module": "dist/src/index.js",
"types": "dist/src/index.d.ts",
Expand Down Expand Up @@ -74,7 +74,7 @@
"src/**"
],
"exclude": [
"src/cmd.js",
"src/cli.js",
"src/index.js"
],
"lines": 85,
Expand Down
File renamed without changes.