style: reformatted all files
This commit is contained in:
@@ -2,6 +2,7 @@ package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
pb "datarush/pkg/api/task"
|
||||
|
||||
"google.golang.org/protobuf/types/known/emptypb"
|
||||
@@ -41,7 +42,10 @@ func (s *TaskService) DeleteTask(ctx context.Context, req *pb.DeleteTaskRequest)
|
||||
return &emptypb.Empty{}, err
|
||||
}
|
||||
|
||||
func (s *TaskService) ListCompetitionTasks(ctx context.Context, req *pb.ListCompetitionTasksRequest) (*pb.ListCompetitionTasksResponse, error) {
|
||||
func (s *TaskService) ListCompetitionTasks(
|
||||
ctx context.Context,
|
||||
req *pb.ListCompetitionTasksRequest,
|
||||
) (*pb.ListCompetitionTasksResponse, error) {
|
||||
tasks, err := s.repo.ListCompetitionTasks(ctx, req.CompetitionId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -49,7 +53,10 @@ func (s *TaskService) ListCompetitionTasks(ctx context.Context, req *pb.ListComp
|
||||
return &pb.ListCompetitionTasksResponse{Tasks: tasks}, nil
|
||||
}
|
||||
|
||||
func (s *TaskService) GetTaskAttachments(ctx context.Context, req *pb.GetTaskAttachmentsRequest) (*pb.GetTaskAttachmentsResponse, error) {
|
||||
func (s *TaskService) GetTaskAttachments(
|
||||
ctx context.Context,
|
||||
req *pb.GetTaskAttachmentsRequest,
|
||||
) (*pb.GetTaskAttachmentsResponse, error) {
|
||||
showPrivate := false
|
||||
if req.ShowPrivate != nil {
|
||||
showPrivate = *req.ShowPrivate
|
||||
@@ -59,4 +66,4 @@ func (s *TaskService) GetTaskAttachments(ctx context.Context, req *pb.GetTaskAtt
|
||||
return nil, err
|
||||
}
|
||||
return &pb.GetTaskAttachmentsResponse{Attachments: attachments}, nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
"datarush/internal/task/service/mocks"
|
||||
pb "datarush/pkg/api/task"
|
||||
|
||||
"go.uber.org/mock/gomock"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"go.uber.org/mock/gomock"
|
||||
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
)
|
||||
@@ -24,13 +24,13 @@ func TestTaskService(t *testing.T) {
|
||||
|
||||
t.Run("CreateTask", func(t *testing.T) {
|
||||
task := &pb.Task{
|
||||
CompetitionId: "comp1",
|
||||
Title: "Test Task",
|
||||
Description: "This is a test task",
|
||||
CompetitionId: "comp1",
|
||||
Title: "Test Task",
|
||||
Description: "This is a test task",
|
||||
InCompetitionPosition: 1,
|
||||
MaxPoints: 100,
|
||||
MaxAttempts: 10,
|
||||
Type: pb.TaskType_TASK_TYPE_INPUT,
|
||||
MaxPoints: 100,
|
||||
MaxAttempts: 10,
|
||||
Type: pb.TaskType_TASK_TYPE_INPUT,
|
||||
}
|
||||
|
||||
mockRepo.EXPECT().CreateTask(ctx, task).Return(task, nil)
|
||||
@@ -44,16 +44,16 @@ func TestTaskService(t *testing.T) {
|
||||
taskID := "task1"
|
||||
req := &pb.GetTaskRequest{TaskId: taskID}
|
||||
expectedTask := &pb.Task{
|
||||
Id: taskID,
|
||||
CompetitionId: "comp1",
|
||||
Title: "Test Task",
|
||||
Description: "This is a test task",
|
||||
Id: taskID,
|
||||
CompetitionId: "comp1",
|
||||
Title: "Test Task",
|
||||
Description: "This is a test task",
|
||||
InCompetitionPosition: 1,
|
||||
MaxPoints: 100,
|
||||
MaxAttempts: 10,
|
||||
Type: pb.TaskType_TASK_TYPE_INPUT,
|
||||
CreatedAt: timestamppb.Now(),
|
||||
UpdatedAt: timestamppb.Now(),
|
||||
MaxPoints: 100,
|
||||
MaxAttempts: 10,
|
||||
Type: pb.TaskType_TASK_TYPE_INPUT,
|
||||
CreatedAt: timestamppb.Now(),
|
||||
UpdatedAt: timestamppb.Now(),
|
||||
}
|
||||
|
||||
mockRepo.EXPECT().GetTask(ctx, taskID).Return(expectedTask, nil)
|
||||
@@ -65,14 +65,14 @@ func TestTaskService(t *testing.T) {
|
||||
|
||||
t.Run("EditTask", func(t *testing.T) {
|
||||
task := &pb.Task{
|
||||
Id: "task1",
|
||||
CompetitionId: "comp1",
|
||||
Title: "Updated Test Task",
|
||||
Description: "This is an updated test task",
|
||||
Id: "task1",
|
||||
CompetitionId: "comp1",
|
||||
Title: "Updated Test Task",
|
||||
Description: "This is an updated test task",
|
||||
InCompetitionPosition: 1,
|
||||
MaxPoints: 150,
|
||||
MaxAttempts: 5,
|
||||
Type: pb.TaskType_TASK_TYPE_CHECKER,
|
||||
MaxPoints: 150,
|
||||
MaxAttempts: 5,
|
||||
Type: pb.TaskType_TASK_TYPE_CHECKER,
|
||||
}
|
||||
|
||||
mockRepo.EXPECT().EditTask(ctx, task).Return(task, nil)
|
||||
@@ -137,4 +137,4 @@ func TestTaskService(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, expectedAttachments, resp.Attachments)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user