loopback-next icon indicating copy to clipboard operation
loopback-next copied to clipboard

CLI tests are not following the correct naming convention.

Open SharonItz opened this issue 7 years ago • 2 comments

In folder /packages/cli/test/fixtures/repository/models there are model files that are used in the CLI tests. I found two issues with the current models both of them rleated to how class name converted into file name. so when the CLI tries to load the file from disk it fails model file not found.

Current behavior running npm test all the current tests are successfully completed.

Expected Behavior some test should fail because it's not using the correct naming convention.

suggested solution the decoratordefined.model.txt file should have a class definition of Decoratordefined instead the class name is DecoratorDefined. the defaultmodel.model.txt file should have a class definition of Defaultmodel instead the class name is DefaultModel. after changing the class name I was able to run all tests successfully.

$ git diff packages/cli/test/fixtures/|cat
diff --git a/packages/cli/test/fixtures/repository/models/decoratordefined.model.txt b/packages/cli/test/fixtures/repository/models/dec oratordefined.model.txt
index 310477c..3b1d304 100644
--- a/packages/cli/test/fixtures/repository/models/decoratordefined.model.txt
+++ b/packages/cli/test/fixtures/repository/models/decoratordefined.model.txt
@@ -7,11 +7,11 @@ import {Entity, model} from '@loopback/repository';
name: {type: 'string', required: true},
},
})

  • export class DecoratorDefined extends Entity {
  • export class Decoratordefined extends Entity {
    thePK: number;
    name: string;
  •  constructor(data?: Partial) {                                                                                 
    
  •  constructor(data?: Partial) {                                                                                 
       super(data);                                                                                                                  
     }                                                                                                                               
    
    }
    diff --git a/packages/cli/test/fixtures/repository/models/defaultmodel.model.txt b/packages/cli/test/fixtures/repository/models/default model.model.txt
    index aa48e75..aa39955 100644
    --- a/packages/cli/test/fixtures/repository/models/defaultmodel.model.txt
    +++ b/packages/cli/test/fixtures/repository/models/defaultmodel.model.txt
    @@ -1,7 +1,7 @@
    import {Entity, model, property} from '@loopback/repository';

@model()
-export class DefaultModel extends Entity {
+export class Defaultmodel extends Entity {
@property({
type: 'number',
id: true,
@@ -20,7 +20,7 @@ export class DefaultModel extends Entity {
})
balance?: number;

  • constructor(data?: Partial) {
  • constructor(data?: Partial) {
    super(data);
    }
    }

SharonItz avatar Feb 17 '19 16:02 SharonItz

@SharonItz Good catch. Would you like to submit a patch?

raymondfeng avatar Feb 17 '19 18:02 raymondfeng

@SharonItz Good catch. Would you like to submit a patch?

Hi @raymondfeng we will submit the patch

thx

SharonItz avatar Feb 18 '19 08:02 SharonItz