Skip to content

Commit

Permalink
update test case
Browse files Browse the repository at this point in the history
  • Loading branch information
LinboLen committed Jul 8, 2024
1 parent 8d14ce2 commit d85d919
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ permissions:
jobs:
main:
runs-on: ubuntu-latest
services:
mysql:
image: mariadb:lts
env:
MARIADB_ALLOW_EMPTY_PASSWORD: yes
MARIADB_ROOT_PASSWORD: 123456
MARIADB_DATABASE: test
ports:
- 3306:3306
options: --health-cmd="healthcheck.sh --connect --innodb_initialized" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- uses: actions/checkout@v4
with:
Expand Down
10 changes: 8 additions & 2 deletions apps/polymorphic-relationships/src/app/app.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@ describe('AppController', () => {
beforeAll(async () => {
app = await Test.createTestingModule({
controllers: [AppController],
providers: [],
providers: []
}).compile();
});

describe('getData', () => {
describe('getData', async () => {
const controller = app.get(AppController);
await controller.addPost();
await controller.createPostImage();
const { list } = await controller.getImages();
expect(list.length).toBeGreaterThan(0);
});
});

8 changes: 3 additions & 5 deletions apps/polymorphic-relationships/src/app/models/image.model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
Column, CreatedAtColumn,
Column, CreatedAtColumn, FedacoRelationType,
forwardRef,
Model,
MorphToColumn,
Expand All @@ -25,13 +25,11 @@ export class Image extends Model {

@MorphToColumn({
morphTypeMap: {
'Post': forwardRef(() => Post),
'User': forwardRef(() => User),
'test_user': forwardRef(() => User),
'test_post': forwardRef(() => Post),
'test_post': forwardRef(() => Post)
}
})
imageable: any;
imageable: FedacoRelationType<User | Post>;

@UpdatedAtColumn()
updated_at: Date;
Expand Down
7 changes: 4 additions & 3 deletions apps/polymorphic-relationships/src/app/models/user.model.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import {
Column,
CreatedAtColumn,
FedacoRelationType,
forwardRef,
Model,
MorphOneColumn,
PrimaryGeneratedColumn, RelationType,
Table, UpdatedAtColumn,
FedacoRelationType
PrimaryGeneratedColumn,
Table,
UpdatedAtColumn
} from '@gradii/fedaco';
import { Image } from './image.model';

Expand Down

0 comments on commit d85d919

Please sign in to comment.