• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

AngelAbelSuarez / Backend-Challenge-Nest / #4

02 Apr 2026 12:18AM UTC coverage: 42.91% (-28.4%) from 71.269%
#4

push

AngelAbelSuarez
bugfix: update test:cov

49 of 114 branches covered (42.98%)

Branch coverage included in aggregate %.

26 of 70 new or added lines in 9 files covered. (37.14%)

34 existing lines in 3 files now uncovered.

66 of 154 relevant lines covered (42.86%)

0.45 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

66.67
/src/users/users.controller.ts
1
import {
1✔
2
  Controller,
3
  Get,
4
  Post,
5
  Body,
6
  Patch,
7
  Param,
8
  Delete,
9
} from '@nestjs/common';
10
import {
1✔
11
  ApiTags,
12
  ApiOperation,
13
  ApiResponse,
14
  ApiParam,
15
  ApiBody,
16
  ApiConflictResponse,
17
  ApiInternalServerErrorResponse,
18
  ApiBadRequestResponse,
19
} from '@nestjs/swagger';
20
import { UsersService } from './users.service';
1✔
21
import {
1✔
22
  CreateUserDto,
23
  UpdateUserDto,
24
  RespondUserDto,
25
  RespondUserDragonBallZDto,
26
} from './dto';
27

28
@ApiTags('users')
29
@Controller('users')
30
export class UsersController {
1✔
NEW
31
  constructor(private readonly usersService: UsersService) {}
×
32

33
  @Post()
34
  @ApiOperation({ summary: 'Create user' })
35
  @ApiBody({ type: CreateUserDto })
36
  @ApiResponse({
37
    status: 201,
38
    description: 'The user has been successfully created.',
39
    type: RespondUserDto,
40
  })
41
  @ApiBadRequestResponse({
42
    description: 'Bad request',
43
    schema: {
44
      example: {
45
        message: [
46
          'name must be a string',
47
          'name should not be empty',
48
          'email must be an email',
49
          'email must be a string',
50
          'email should not be empty',
51
          'password must be a string',
52
          'password should not be empty',
53
        ],
54
        error: 'Bad Request',
55
        statusCode: 400,
56
      },
57
    },
58
  })
59
  @ApiConflictResponse({
60
    description: 'Email already exists',
61
    schema: {
62
      example: {
63
        message: 'Email already exists',
64
        error: 'Conflict',
65
        statusCode: 409,
66
      },
67
    },
68
  })
69
  @ApiInternalServerErrorResponse({
70
    description: 'Internal server error',
71
    schema: {
72
      example: {
73
        message: 'Internal server error',
74
        error: 'Internal Server Error',
75
        statusCode: 500,
76
      },
77
    },
78
  })
79
  async create(@Body() createUserDto: CreateUserDto): Promise<RespondUserDto> {
1!
UNCOV
80
    const userData = {
×
81
      ...createUserDto,
82
      dragonBallZIds: createUserDto.dragonBallZIds || [],
×
83
    };
UNCOV
84
    return this.usersService.create(userData);
×
85
  }
86

87
  @Get()
88
  @ApiOperation({ summary: 'Get all users' })
89
  @ApiResponse({
90
    status: 200,
91
    description: 'Return all users.',
92
    type: [RespondUserDto],
93
  })
94
  @ApiInternalServerErrorResponse({
95
    description: 'Internal server error',
96
    schema: {
97
      example: {
98
        message: 'Internal server error',
99
        error: 'Internal Server Error',
100
        statusCode: 500,
101
      },
102
    },
103
  })
104
  async findAll(): Promise<RespondUserDto[]> {
1!
UNCOV
105
    return this.usersService.findAll();
×
106
  }
107

108
  @Get(':id')
109
  @ApiOperation({ summary: 'Get user by id' })
110
  @ApiParam({ name: 'id', description: 'User id' })
111
  @ApiResponse({
112
    status: 200,
113
    description: 'Return the user.',
114
    type: RespondUserDragonBallZDto,
115
  })
116
  @ApiResponse({
117
    status: 404,
118
    description: 'User not found.',
119
    schema: {
120
      example: {
121
        message: 'User with id 17a6b856-03d8-44a5-a87f-cf76fcc67f45 not found',
122
        error: 'Not Found',
123
        statusCode: 404,
124
      },
125
    },
126
  })
127
  async findById(
1✔
128
    @Param('id') id: string,
129
  ): Promise<RespondUserDragonBallZDto | undefined> {
3!
UNCOV
130
    return this.usersService.findByIdwIThDragonBallZ(id);
×
131
  }
132

133
  @Patch(':id')
134
  @ApiOperation({ summary: 'Update user' })
135
  @ApiParam({ name: 'id', description: 'User id' })
136
  @ApiBody({ type: UpdateUserDto })
137
  @ApiResponse({
138
    status: 200,
139
    description: 'The user has been successfully updated.',
140
    type: RespondUserDto,
141
  })
142
  @ApiResponse({
143
    status: 404,
144
    description: 'User not found.',
145
    schema: {
146
      example: {
147
        message: 'User with id 17a6b856-03d8-44a5-a87f-cf76fcc67f45 not found',
148
        error: 'Not Found',
149
        statusCode: 404,
150
      },
151
    },
152
  })
153
  @ApiConflictResponse({
154
    description: 'Email already exists',
155
    schema: {
156
      example: {
157
        message: 'Email already exists',
158
        error: 'Conflict',
159
        statusCode: 409,
160
      },
161
    },
162
  })
163
  @ApiInternalServerErrorResponse({
164
    description: 'Internal server error',
165
    schema: {
166
      example: {
167
        message: 'Internal server error',
168
        error: 'Internal Server Error',
169
        statusCode: 500,
170
      },
171
    },
172
  })
173
  async update(
1✔
174
    @Param('id') id: string,
175
    @Body() updateUserDto: UpdateUserDto,
3!
176
  ): Promise<RespondUserDto> {
3!
UNCOV
177
    return this.usersService.update(id, updateUserDto);
×
178
  }
179

180
  @Delete(':id')
181
  @ApiOperation({ summary: 'Delete user' })
182
  @ApiParam({ name: 'id', description: 'User id' })
183
  @ApiResponse({ status: 200, description: 'OK', type: Boolean })
184
  @ApiResponse({
185
    status: 404,
186
    description: 'User not found.',
187
    schema: {
188
      example: {
189
        message: 'User with id 17a6b856-03d8-44a5-a87f-cf76fcc67f45 not found',
190
        error: 'Not Found',
191
        statusCode: 404,
192
      },
193
    },
194
  })
195
  @ApiInternalServerErrorResponse({
196
    description: 'Internal server error',
197
    schema: {
198
      example: {
199
        message: 'Internal server error',
200
        error: 'Internal Server Error',
201
        statusCode: 500,
202
      },
203
    },
204
  })
205
  async remove(@Param('id') id: string): Promise<boolean> {
1!
UNCOV
206
    return this.usersService.delete(id);
×
207
  }
208
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc