DTaaS icon indicating copy to clipboard operation
DTaaS copied to clipboard

Integrate gitbeaker API into client codebase

Open VanessaScherma opened this issue 1 year ago • 7 comments

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 avatar Jun 20 '24 21:06 VanessaScherma

@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.

prasadtalasila avatar Jun 25 '24 09:06 prasadtalasila

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.

Files with missing lines Patch % Lines
client/src/util/gitlabDriver.ts 0.00% 23 Missing and 1 partial :warning:
client/src/util/gitlabDigitalTwin.ts 81.81% 2 Missing and 2 partials :warning:
client/src/util/gitlab.ts 89.28% 0 Missing and 3 partials :warning:
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 ∅ <ø> (∅)

codecov-commenter avatar Aug 01 '24 15:08 codecov-commenter

The commands to run the gitlabDriver file are:

  1. yarn install
  2. npx tsc
  3. cd dist/src/util
  4. In 'gitlabDriver.js', change './gitlab' to './gitlab.js' and './gitlabDigitalTwin' to './gitlabDigitalTwin.js'
  5. node gitlabDriver.js

The correct functioning of the API will be visible in the terminal.

VanessaScherma avatar Aug 07 '24 10:08 VanessaScherma

The commands to run the gitlabDriver file are:

  1. yarn install
  2. npx tsc
  3. cd dist/src/util
  4. In 'gitlabDriver.js', change './gitlab' to './gitlab.js' and './gitlabDigitalTwin' to './gitlabDigitalTwin.js'
  5. 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';

prasadtalasila avatar Aug 07 '24 12:08 prasadtalasila

The updated commands are:

  1. yarn install
  2. npx tsc
  3. cd dist/src/util
  4. node gitlabDriver.js

The only errors that npx tsc gives are related to other files, but it still works.

VanessaScherma avatar Aug 07 '24 15:08 VanessaScherma

@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.

prasadtalasila avatar Aug 19 '24 16:08 prasadtalasila

Code Climate has analyzed commit d54bbb8d and detected 0 issues on this pull request.

View more on Code Climate.

qlty-cloud-legacy[bot] avatar Aug 23 '24 07:08 qlty-cloud-legacy[bot]

merged via PR #894

prasadtalasila avatar Aug 29 '24 10:08 prasadtalasila