chore(api): remove obsolete team module (#2138)
Signed-off-by: fabjanvucina <fabjanvucina@gmail.com>
This commit is contained in:
@@ -7,7 +7,6 @@ import { Module, NestModule, MiddlewareConsumer, RequestMethod } from '@nestjs/c
|
||||
import { VersionHeaderMiddleware } from './common/middleware/version-header.middleware'
|
||||
import { AppService } from './app.service'
|
||||
import { UserModule } from './user/user.module'
|
||||
import { TeamModule } from './team/team.module'
|
||||
import { TypeOrmModule } from '@nestjs/typeorm'
|
||||
import { SandboxModule } from './sandbox/sandbox.module'
|
||||
import { AuthModule } from './auth/auth.module'
|
||||
@@ -85,7 +84,6 @@ import { MaintenanceMiddleware } from './common/middleware/maintenance.middlewar
|
||||
ApiKeyModule,
|
||||
AuthModule,
|
||||
UserModule,
|
||||
TeamModule,
|
||||
SandboxModule,
|
||||
DockerRegistryModule,
|
||||
ScheduleModule.forRoot(),
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm'
|
||||
|
||||
export class Migration1752494676200 implements MigrationInterface {
|
||||
name = 'Migration1752494676200'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`DROP TABLE "team"`)
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "team" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "name" character varying NOT NULL, CONSTRAINT "PK_f57d8293406df4af348402e4b74" PRIMARY KEY ("id"))`,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
export class CreateTeamDto {
|
||||
name: string
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { Team } from './team.entity'
|
||||
|
||||
describe('Team', () => {
|
||||
it('should be defined', () => {
|
||||
expect(new Team()).toBeDefined()
|
||||
})
|
||||
})
|
||||
@@ -1,15 +0,0 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm'
|
||||
|
||||
@Entity()
|
||||
export class Team {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string
|
||||
|
||||
@Column()
|
||||
name: string
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { Module } from '@nestjs/common'
|
||||
import { TeamService } from './team.service'
|
||||
import { TypeOrmModule } from '@nestjs/typeorm'
|
||||
import { Team } from './team.entity'
|
||||
|
||||
@Module({
|
||||
imports: [TypeOrmModule.forFeature([Team])],
|
||||
providers: [TeamService],
|
||||
})
|
||||
export class TeamModule {}
|
||||
@@ -1,95 +0,0 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { Test, TestingModule } from '@nestjs/testing'
|
||||
import { TeamService } from './team.service'
|
||||
import { getRepositoryToken } from '@nestjs/typeorm'
|
||||
import { Team } from './team.entity'
|
||||
import { Repository } from 'typeorm'
|
||||
|
||||
const teamArray: Team[] = [
|
||||
{
|
||||
id: '1',
|
||||
name: 'team #1',
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
name: 'team #2',
|
||||
},
|
||||
]
|
||||
|
||||
const oneTeam: Team = {
|
||||
id: '1',
|
||||
name: 'team #1',
|
||||
}
|
||||
|
||||
describe('TeamService', () => {
|
||||
let service: TeamService
|
||||
let repository: Repository<Team>
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [
|
||||
TeamService,
|
||||
{
|
||||
provide: getRepositoryToken(Team),
|
||||
useValue: {
|
||||
find: jest.fn().mockResolvedValue(teamArray),
|
||||
findOneBy: jest.fn().mockResolvedValue(oneTeam),
|
||||
save: jest.fn().mockResolvedValue(oneTeam),
|
||||
remove: jest.fn(),
|
||||
delete: jest.fn(),
|
||||
},
|
||||
},
|
||||
],
|
||||
}).compile()
|
||||
|
||||
service = module.get<TeamService>(TeamService)
|
||||
repository = module.get<Repository<Team>>(getRepositoryToken(Team))
|
||||
})
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(service).toBeDefined()
|
||||
})
|
||||
|
||||
describe('create()', () => {
|
||||
it('should successfully insert a team', () => {
|
||||
const oneTeam: Team = {
|
||||
id: '1',
|
||||
name: 'team #1',
|
||||
}
|
||||
|
||||
expect(
|
||||
service.create({
|
||||
name: oneTeam.name,
|
||||
}),
|
||||
).resolves.toEqual(oneTeam)
|
||||
})
|
||||
})
|
||||
|
||||
describe('findAll()', () => {
|
||||
it('should return an array of teams', async () => {
|
||||
const teams = await service.findAll()
|
||||
expect(teams).toEqual(teamArray)
|
||||
})
|
||||
})
|
||||
|
||||
describe('findOne()', () => {
|
||||
it('should get a single team', () => {
|
||||
const repoSpy = jest.spyOn(repository, 'findOneBy')
|
||||
expect(service.findOne('6d225ef9-b6e1-4061-81c6-a9cf639a8897')).resolves.toEqual(oneTeam)
|
||||
expect(repoSpy).toHaveBeenCalledWith({ id: '6d225ef9-b6e1-4061-81c6-a9cf639a8897' })
|
||||
})
|
||||
})
|
||||
|
||||
describe('remove()', () => {
|
||||
it('should call remove with the passed value', async () => {
|
||||
const removeSpy = jest.spyOn(repository, 'delete')
|
||||
const retVal = await service.remove('2')
|
||||
expect(removeSpy).toHaveBeenCalledWith('2')
|
||||
expect(retVal).toBeUndefined()
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0
|
||||
*/
|
||||
|
||||
import { Injectable } from '@nestjs/common'
|
||||
import { InjectRepository } from '@nestjs/typeorm'
|
||||
import { Team } from './team.entity'
|
||||
import { Repository } from 'typeorm'
|
||||
import { CreateTeamDto } from './dto/create-team.dto'
|
||||
|
||||
@Injectable()
|
||||
export class TeamService {
|
||||
constructor(
|
||||
@InjectRepository(Team)
|
||||
private readonly teamRepository: Repository<Team>,
|
||||
) {}
|
||||
|
||||
create(createUserDto: CreateTeamDto): Promise<Team> {
|
||||
const team = new Team()
|
||||
team.name = createUserDto.name
|
||||
|
||||
return this.teamRepository.save(team)
|
||||
}
|
||||
|
||||
async findAll(): Promise<Team[]> {
|
||||
return this.teamRepository.find()
|
||||
}
|
||||
|
||||
findOne(id: string): Promise<Team> {
|
||||
return this.teamRepository.findOneBy({ id: id })
|
||||
}
|
||||
|
||||
async remove(id: string): Promise<void> {
|
||||
await this.teamRepository.delete(id)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user