-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore:SP-1924 Adds copyleft policy unit tests
- Loading branch information
1 parent
4cbecae
commit f22e879
Showing
11 changed files
with
697 additions
and
81 deletions.
There are no files selected for viewing
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
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,129 @@ | ||
import { | ||
COPYLEFT_LICENSE_EXCLUDE, | ||
COPYLEFT_LICENSE_EXPLICIT, | ||
COPYLEFT_LICENSE_INCLUDE, | ||
OUTPUT_FILEPATH, | ||
REPO_DIR, | ||
RUNTIME_CONTAINER | ||
} from '../src/app.input'; | ||
import { CopyLeftArgumentBuilder } from '../src/policies/argument_builders/copyleft-argument-builder'; | ||
|
||
describe('CopyleftArgumentBuilder', () => { | ||
const defaultCopyleftLicenseExplicit = COPYLEFT_LICENSE_EXPLICIT; | ||
const defaultCopyleftLicenseExclude = COPYLEFT_LICENSE_EXCLUDE; | ||
const defaultCopyleftLicenseInclude = COPYLEFT_LICENSE_INCLUDE; | ||
|
||
afterEach(() => { | ||
// Restore all mocks | ||
jest.restoreAllMocks(); | ||
(COPYLEFT_LICENSE_EXPLICIT as any) = defaultCopyleftLicenseExplicit; | ||
(COPYLEFT_LICENSE_EXCLUDE as any) = defaultCopyleftLicenseExclude; | ||
(COPYLEFT_LICENSE_INCLUDE as any) = defaultCopyleftLicenseInclude; | ||
}); | ||
|
||
test('Copyleft explicit test', async () => { | ||
(COPYLEFT_LICENSE_EXPLICIT as any) = 'MIT,Apache-2.0'; | ||
(COPYLEFT_LICENSE_EXCLUDE as any) = 'MIT,Apache-2.0'; | ||
(REPO_DIR as any) = 'scanoss'; | ||
(OUTPUT_FILEPATH as any) = 'results.json'; | ||
|
||
const builder = new CopyLeftArgumentBuilder(); | ||
const cmd = await builder.build(); | ||
expect(cmd).toEqual([ | ||
'run', | ||
'-v', | ||
'scanoss:/scanoss', | ||
'ghcr.io/scanoss/scanoss-py:v1.18.0', | ||
'inspect', | ||
'copyleft', | ||
'--input', | ||
'results.json', | ||
'--format', | ||
'md', | ||
'--explicit', | ||
'MIT,Apache-2.0' | ||
]); | ||
}); | ||
|
||
test('Copyleft exclude test', async () => { | ||
(COPYLEFT_LICENSE_EXCLUDE as any) = 'MIT,Apache-2.0'; | ||
(REPO_DIR as any) = 'scanoss'; | ||
(OUTPUT_FILEPATH as any) = 'results.json'; | ||
const builder = new CopyLeftArgumentBuilder(); | ||
const cmd = await builder.build(); | ||
expect(cmd).toEqual([ | ||
'run', | ||
'-v', | ||
'scanoss:/scanoss', | ||
'ghcr.io/scanoss/scanoss-py:v1.18.0', | ||
'inspect', | ||
'copyleft', | ||
'--input', | ||
'results.json', | ||
'--format', | ||
'md', | ||
'--exclude', | ||
'MIT,Apache-2.0' | ||
]); | ||
}); | ||
|
||
test('Copyleft include test', async () => { | ||
(COPYLEFT_LICENSE_INCLUDE as any) = 'MIT,Apache-2.0,LGPL-3.0-only'; | ||
(REPO_DIR as any) = 'scanoss'; | ||
(OUTPUT_FILEPATH as any) = 'results.json'; | ||
const builder = new CopyLeftArgumentBuilder(); | ||
const cmd = await builder.build(); | ||
expect(cmd).toEqual([ | ||
'run', | ||
'-v', | ||
'scanoss:/scanoss', | ||
'ghcr.io/scanoss/scanoss-py:v1.18.0', | ||
'inspect', | ||
'copyleft', | ||
'--input', | ||
'results.json', | ||
'--format', | ||
'md', | ||
'--include', | ||
'MIT,Apache-2.0,LGPL-3.0-only' | ||
]); | ||
}); | ||
|
||
test('Copyleft empty parameters test', async () => { | ||
(REPO_DIR as any) = 'scanoss'; | ||
(OUTPUT_FILEPATH as any) = 'results.json'; | ||
const builder = new CopyLeftArgumentBuilder(); | ||
const cmd = await builder.build(); | ||
expect(cmd).toEqual([ | ||
'run', | ||
'-v', | ||
'scanoss:/scanoss', | ||
RUNTIME_CONTAINER, | ||
'inspect', | ||
'copyleft', | ||
'--input', | ||
'results.json', | ||
'--format', | ||
'md' | ||
]); | ||
}); | ||
|
||
test('Build Command test', async () => { | ||
(REPO_DIR as any) = 'scanoss'; | ||
(OUTPUT_FILEPATH as any) = 'results.json'; | ||
const builder = new CopyLeftArgumentBuilder(); | ||
const cmd = await builder.build(); | ||
expect(cmd).toEqual([ | ||
'run', | ||
'-v', | ||
'scanoss:/scanoss', | ||
RUNTIME_CONTAINER, | ||
'inspect', | ||
'copyleft', | ||
'--input', | ||
'results.json', | ||
'--format', | ||
'md' | ||
]); | ||
}); | ||
}); |
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
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,50 @@ | ||
{ | ||
"crc32c.c": [ | ||
{ | ||
"id": "none", | ||
"server": { | ||
"kb_version": { | ||
"daily": "24.11.12", | ||
"monthly": "24.10" | ||
}, | ||
"version": "5.4.8" | ||
} | ||
} | ||
], | ||
"json.c": [ | ||
{ | ||
"id": "none", | ||
"server": { | ||
"kb_version": { | ||
"daily": "24.11.12", | ||
"monthly": "24.10" | ||
}, | ||
"version": "5.4.8" | ||
} | ||
} | ||
], | ||
"log.c": [ | ||
{ | ||
"id": "none", | ||
"server": { | ||
"kb_version": { | ||
"daily": "24.11.12", | ||
"monthly": "24.10" | ||
}, | ||
"version": "5.4.8" | ||
} | ||
} | ||
], | ||
"package.json": [ | ||
{ | ||
"id": "none", | ||
"server": { | ||
"kb_version": { | ||
"daily": "24.11.12", | ||
"monthly": "24.10" | ||
}, | ||
"version": "5.4.8" | ||
} | ||
} | ||
] | ||
} |
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,28 @@ | ||
{ | ||
"name": "scanoss", | ||
"version": "0.15.3", | ||
"description": "The SCANOSS JS package provides a simple, easy to consume module for interacting with SCANOSS APIs/Engine.", | ||
"main": "build/main/index.js", | ||
"typings": "build/main/index.d.ts", | ||
"module": "build/module/index.js", | ||
"repository": "https://github.com/scanoss/scanoss.js", | ||
"license": "MIT", | ||
"keywords": [], | ||
"bin": { | ||
"scanoss-js": "build/main/cli/bin/cli-bin.js" | ||
}, | ||
"scripts": { | ||
"build": "run-p build:*", | ||
"build:main": "tsc -p tsconfig.json", | ||
"build:module": "tsc -p tsconfig.module.json", | ||
"test": "nyc mocha -r ts-node/register 'tests/**/*.ts' 'src/**/*.spec.ts'", | ||
"install-dev": "npm run build && npm run test && npm install -g ." | ||
}, | ||
"engines": { | ||
"node": ">=10" | ||
}, | ||
"dependencies": { | ||
"@grpc/grpc-js": "^1.5.5", | ||
"abort-controller": "^3.0.0" | ||
} | ||
} |
Oops, something went wrong.