Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): change location fixtures service/repository
- Loading branch information
1 parent
9bafc6d
commit d4f5b5c
Showing
10 changed files
with
260 additions
and
324 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,89 @@ | ||
const DATASOURCE_APP_PATH = 'src/datasources'; | ||
const MODEL_APP_PATH = 'src/models'; | ||
const CONFIG_PATH = '.'; | ||
const DUMMY_CONTENT = '--DUMMY VALUE--'; | ||
const fs = require('fs'); | ||
|
||
exports.SANDBOX_FILES = [ | ||
{ | ||
path: CONFIG_PATH, | ||
file: 'myconfig.json', | ||
content: JSON.stringify({ | ||
datasource: 'dbmem', | ||
model: 'decoratordefined', | ||
}), | ||
}, | ||
{ | ||
path: DATASOURCE_APP_PATH, | ||
file: 'dbkv.datasource.json', | ||
content: JSON.stringify({ | ||
name: 'dbkv', | ||
connector: 'kv-redis', | ||
}), | ||
}, | ||
{ | ||
path: DATASOURCE_APP_PATH, | ||
file: 'dbkv.datasource.ts', | ||
content: DUMMY_CONTENT, | ||
}, | ||
{ | ||
path: DATASOURCE_APP_PATH, | ||
file: 'dbmem.datasource.json', | ||
content: JSON.stringify({ | ||
name: 'dbmem', | ||
connector: 'memory', | ||
}), | ||
}, | ||
{ | ||
path: DATASOURCE_APP_PATH, | ||
file: 'dbmem.datasource.ts', | ||
content: DUMMY_CONTENT, | ||
}, | ||
{ | ||
path: DATASOURCE_APP_PATH, | ||
file: 'restdb.datasource.json', | ||
content: JSON.stringify({ | ||
name: 'restdb', | ||
connector: 'rest', | ||
}), | ||
}, | ||
{ | ||
path: DATASOURCE_APP_PATH, | ||
file: 'restdb.datasource.ts', | ||
content: DUMMY_CONTENT, | ||
}, | ||
{ | ||
path: MODEL_APP_PATH, | ||
file: 'decoratordefined.model.ts', | ||
content: fs.readFileSync( | ||
require.resolve('./models/decoratordefined.model.txt'), | ||
{ | ||
encoding: 'utf-8', | ||
}, | ||
), | ||
}, | ||
{ | ||
path: MODEL_APP_PATH, | ||
file: 'defaultmodel.model.ts', | ||
content: fs.readFileSync( | ||
require.resolve('./models/defaultmodel.model.txt'), | ||
{ | ||
encoding: 'utf-8', | ||
}, | ||
), | ||
}, | ||
{ | ||
path: MODEL_APP_PATH, | ||
file: 'multi-word.model.ts', | ||
content: fs.readFileSync(require.resolve('./models/multi-word.model.txt'), { | ||
encoding: 'utf-8', | ||
}), | ||
}, | ||
{ | ||
path: MODEL_APP_PATH, | ||
file: 'invalid-id.model.ts', | ||
content: fs.readFileSync(require.resolve('./models/invalid-id.model.txt'), { | ||
encoding: 'utf-8', | ||
}), | ||
}, | ||
]; |
17 changes: 17 additions & 0 deletions
17
packages/cli/test/fixtures/repository/models/decoratordefined.model.txt
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,17 @@ | ||
import {Entity, model} from '@loopback/repository'; | ||
|
||
@model({ | ||
name: 'Product', | ||
properties: { | ||
thePK: {type: 'number', id: true}, | ||
name: {type: 'string', required: true}, | ||
}, | ||
}) | ||
export class DecoratorDefined extends Entity { | ||
thePK: number; | ||
name: string; | ||
|
||
constructor(data?: Partial<DecoratorDefined>) { | ||
super(data); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
packages/cli/test/fixtures/repository/models/defaultmodel.model.txt
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,26 @@ | ||
import {Entity, model, property} from '@loopback/repository'; | ||
|
||
@model() | ||
export class DefaultModel extends Entity { | ||
@property({ | ||
type: 'number', | ||
id: true, | ||
default: 0, | ||
}) | ||
id?: number; | ||
|
||
@property({ | ||
type: 'string', | ||
}) | ||
desc?: string; | ||
|
||
@property({ | ||
type: 'number', | ||
default: 0, | ||
}) | ||
balance?: number; | ||
|
||
constructor(data?: Partial<DefaultModel>) { | ||
super(data); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
packages/cli/test/fixtures/repository/models/invalid-id.model.txt
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,20 @@ | ||
import {Entity, model, property} from '@loopback/repository'; | ||
|
||
@model() | ||
export class InvalidID extends Entity { | ||
@property({ | ||
type: 'string', | ||
required: true, | ||
default: 0, | ||
}) | ||
id: string; | ||
|
||
@property({ | ||
type: 'string', | ||
}) | ||
desc?: string; | ||
|
||
constructor(data?: Partial<InvalidID>) { | ||
super(data); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
packages/cli/test/fixtures/repository/models/multi-word.model.txt
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,20 @@ | ||
import {Entity, model, property} from '@loopback/repository'; | ||
|
||
@model() | ||
export class MultiWord extends Entity { | ||
@property({ | ||
type: 'string', | ||
id: true, | ||
default: 0, | ||
}) | ||
pk?: string; | ||
|
||
@property({ | ||
type: 'string', | ||
}) | ||
desc?: string; | ||
|
||
constructor(data?: Partial<MultiWord>) { | ||
super(data); | ||
} | ||
} |
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,61 @@ | ||
const DATASOURCE_APP_PATH = 'src/datasources'; | ||
const CONFIG_PATH = '.'; | ||
const DUMMY_CONTENT = '--DUMMY VALUE--'; | ||
|
||
exports.SANDBOX_FILES = [ | ||
{ | ||
path: CONFIG_PATH, | ||
file: 'mysoapconfig.json', | ||
content: JSON.stringify({ | ||
name: 'MultiWordService', | ||
datasource: 'myds', | ||
}), | ||
}, | ||
{ | ||
path: CONFIG_PATH, | ||
file: 'myrestconfig.json', | ||
content: JSON.stringify({ | ||
name: 'myservice', | ||
datasource: 'restdb', | ||
}), | ||
}, | ||
{ | ||
path: DATASOURCE_APP_PATH, | ||
file: 'myds.datasource.json', | ||
content: JSON.stringify({ | ||
name: 'myds', | ||
connector: 'soap', | ||
}), | ||
}, | ||
{ | ||
path: DATASOURCE_APP_PATH, | ||
file: 'myds.datasource.ts', | ||
content: DUMMY_CONTENT, | ||
}, | ||
{ | ||
path: DATASOURCE_APP_PATH, | ||
file: 'dbmem.datasource.json', | ||
content: JSON.stringify({ | ||
name: 'dbmem', | ||
connector: 'memory', | ||
}), | ||
}, | ||
{ | ||
path: DATASOURCE_APP_PATH, | ||
file: 'dbmem.datasource.ts', | ||
content: DUMMY_CONTENT, | ||
}, | ||
{ | ||
path: DATASOURCE_APP_PATH, | ||
file: 'restdb.datasource.json', | ||
content: JSON.stringify({ | ||
name: 'restdb', | ||
connector: 'rest', | ||
}), | ||
}, | ||
{ | ||
path: DATASOURCE_APP_PATH, | ||
file: 'restdb.datasource.ts', | ||
content: DUMMY_CONTENT, | ||
}, | ||
]; |
Oops, something went wrong.