DTaaS
DTaaS copied to clipboard
Integrate gitbeaker API into client codebase
The problem is that mockGitlabConstructor is instantiated as an empty constructor, without its methods. For example, when using this.api.Projects.search() in the code, mockGitlabConstructor is used in the test but gives an error as the methods like Projects.search() are not inserted inside the mockGitlabConstructor.
I have tried to find more information on the Internet but have not yet been able to solve it. Thank you for your help.
@VanessaScherma you could do dependency injection. To be precise, give an instance of Gitlab to DigitalTwin class via constructor. Then mocking it becomes easier. You just need to implement skeleton functionality of Gitlab to test DigitalTwin class. Module mocking like you are doing is doable as well. Perhaps the injection of Gitlab into DigitalTwin is an easier testing step for now.
Codecov Report
Attention: Patch coverage is 58.10811% with 31 lines in your changes missing coverage. Please review.
Project coverage is 85.93%. Comparing base (
eaa22d5) to head (ea3fd03). Report is 24 commits behind head on feature/distributed-demo.
:exclamation: Current head ea3fd03 differs from pull request most recent head d54bbb8
Please upload reports for the commit d54bbb8 to get more accurate results.
Additional details and impacted files
@@ Coverage Diff @@
## feature/distributed-demo #830 +/- ##
=============================================================
+ Coverage 66.49% 85.93% +19.43%
=============================================================
Files 31 35 +4
Lines 394 519 +125
Branches 26 40 +14
=============================================================
+ Hits 262 446 +184
+ Misses 117 49 -68
- Partials 15 24 +9
| Files with missing lines | Coverage Δ | |
|---|---|---|
| client/src/util/gitlab.ts | 89.28% <89.28%> (ø) |
|
| client/src/util/gitlabDigitalTwin.ts | 81.81% <81.81%> (ø) |
|
| client/src/util/gitlabDriver.ts | 0.00% <0.00%> (ø) |
... and 6 files with indirect coverage changes
| Components | Coverage Δ | |
|---|---|---|
| Website | 85.93% <75.49%> (+19.43%) |
:arrow_up: |
| Lib Microservice | ∅ <ø> (∅) |
The commands to run the gitlabDriver file are:
- yarn install
- npx tsc
- cd dist/src/util
- In 'gitlabDriver.js', change './gitlab' to './gitlab.js' and './gitlabDigitalTwin' to './gitlabDigitalTwin.js'
- node gitlabDriver.js
The correct functioning of the API will be visible in the terminal.
The commands to run the gitlabDriver file are:
- yarn install
- npx tsc
- cd dist/src/util
- In 'gitlabDriver.js', change './gitlab' to './gitlab.js' and './gitlabDigitalTwin' to './gitlabDigitalTwin.js'
- node gitlabDriver.js
The correct functioning of the API will be visible in the terminal.
@VanessaScherma
npx tsc is still throwing up errors. In addition, you can change imports of gitlabDriver.ts to
import GitlabInstance from './gitlab.js';
import DigitalTwin from './gitlabDigitalTwin.js';
The updated commands are:
- yarn install
- npx tsc
- cd dist/src/util
- node gitlabDriver.js
The only errors that npx tsc gives are related to other files, but it still works.
@VanessaScherma
Also when you make the change, the Gitlab&nstance class needs the constructor parameters in the GitlabDriver.ts file. Please keep them in either client/config/gitlab.json and read them into the driver file.
Code Climate has analyzed commit d54bbb8d and detected 0 issues on this pull request.
View more on Code Climate.
merged via PR #894