Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/email/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ type PasswordResetTemplateData struct {
}

// Get returns the password reset email template data.
func (d *PasswordResetTemplateData) Get() interface{} {
func (d *PasswordResetTemplateData) RenderData() interface{} {
return d
}
2 changes: 1 addition & 1 deletion internal/email/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ func TestPasswordResetTemplateData_Get(t *testing.T) {
SupportEmail: "info@example.com",
}

assert.Equal(t, data, data.Get())
assert.Equal(t, data, data.RenderData())
}
2 changes: 1 addition & 1 deletion internal/email/organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ type OrganizationInviteTemplateData struct {
}

// Get returns the invitation email template data.
func (d *OrganizationInviteTemplateData) Get() interface{} {
func (d *OrganizationInviteTemplateData) RenderData() interface{} {
return d
}
2 changes: 1 addition & 1 deletion internal/email/organization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ func TestOrganizationInviteTemplateData_Get(t *testing.T) {
SupportEmail: "info@example.com",
}

assert.Equal(t, data, data.Get())
assert.Equal(t, data, data.RenderData())
}
2 changes: 1 addition & 1 deletion internal/email/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ type LicenseExpiryTemplateData struct {
}

// Get returns the license expiration email template data.
func (d *LicenseExpiryTemplateData) Get() interface{} {
func (d *LicenseExpiryTemplateData) RenderData() interface{} {
return d
}
2 changes: 1 addition & 1 deletion internal/email/system_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ func TestLicenseExpiryTemplateData_Get(t *testing.T) {
SupportEmail: "info@example.com",
}

assert.Equal(t, data, data.Get())
assert.Equal(t, data, data.RenderData())
}
4 changes: 2 additions & 2 deletions internal/email/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
// TemplateData represents the data needed to render an email template.
type TemplateData interface {
// Get returns the template data.
Get() any
RenderData() any
}

// Template is a struct that represents the data needed to render
Expand All @@ -30,7 +30,7 @@ func (t *Template) Validate() error {

// Render returns the rendered template.
func (t *Template) Render() (string, error) {
return emailBody[*template.Template](t.Path, t.Data.Get(), template.ParseFiles)
return emailBody[*template.Template](t.Path, t.Data.RenderData(), template.ParseFiles)
}

// NewTemplate returns a new email template.
Expand Down
2 changes: 1 addition & 1 deletion internal/email/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type testTemplateData struct {
SupportEmail string `validate:"required,email"`
}

func (d *testTemplateData) Get() interface{} {
func (d *testTemplateData) RenderData() interface{} {
return d
}

Expand Down
2 changes: 1 addition & 1 deletion internal/email/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ type UserWelcomeTemplateData struct {
}

// Get returns the welcome email template data.
func (d *UserWelcomeTemplateData) Get() interface{} {
func (d *UserWelcomeTemplateData) RenderData() interface{} {
return d
}
2 changes: 1 addition & 1 deletion internal/email/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ func TestUserWelcomeTemplateData_Get(t *testing.T) {
SupportEmail: "info@example.com",
}

assert.Equal(t, data, data.Get())
assert.Equal(t, data, data.RenderData())
}
4 changes: 2 additions & 2 deletions internal/pkg/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package pkg

// GetDefault returns the value if it is not the zero value of the type, otherwise
// it returns the fallback.
func GetDefault[T comparable](value, fallback T) T {
func RenderDefault[T comparable](value, fallback T) T {
var zero T
if value == zero {
return fallback
Expand All @@ -13,7 +13,7 @@ func GetDefault[T comparable](value, fallback T) T {

// GetDefaultPtr returns the value if it is not nil, otherwise it returns the
// fallback.
func GetDefaultPtr[T any](value *T, fallback T) T {
func RenderDefaultPtr[T any](value *T, fallback T) T {
if value == nil {
return fallback
}
Expand Down
8 changes: 4 additions & 4 deletions internal/pkg/default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/assert"
)

func TestGetDefault(t *testing.T) {
func TestRenderDefault(t *testing.T) {
type args struct {
value int
fallback int
Expand Down Expand Up @@ -38,12 +38,12 @@ func TestGetDefault(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

assert.Equal(t, tt.want, GetDefault(tt.args.value, tt.args.fallback))
assert.Equal(t, tt.want, RenderDefault(tt.args.value, tt.args.fallback))
})
}
}

func TestGetDefaultPtr(t *testing.T) {
func TestRenderDefaultPtr(t *testing.T) {
type args struct {
value *int
fallback int
Expand Down Expand Up @@ -78,7 +78,7 @@ func TestGetDefaultPtr(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

assert.Equal(t, tt.want, GetDefaultPtr(tt.args.value, tt.args.fallback))
assert.Equal(t, tt.want, RenderDefaultPtr(tt.args.value, tt.args.fallback))
})
}
}
2 changes: 1 addition & 1 deletion internal/pkg/smtp/smtp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type testTemplateData struct {
Field string
}

func (t *testTemplateData) Get() any {
func (t *testTemplateData) RenderData() any {
return t
}

Expand Down
1 change: 0 additions & 1 deletion internal/pkg/tracing/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ func NewTracerProvider(ctx context.Context, version *model.VersionInfo, service
if err != nil {
return nil, err
}

tracerProvider := sdktrace.NewTracerProvider(
sdktrace.WithResource(resource.NewWithAttributes(
semconv.SchemaURL,
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/validate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var (
)

// GetValidator returns the validator instance.
func GetValidator() *validator.Validate {
func RenderValidator() *validator.Validate {
return validate
}

Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/validate/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"github.com/stretchr/testify/assert"
)

func TestGetValidator(t *testing.T) {
assert.NotNil(t, GetValidator())
func TestRenderValidator(t *testing.T) {
assert.NotNil(t, RenderValidator())
}

func TestStruct(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions internal/queue/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ func (c *Client) Enqueue(ctx context.Context, task *asynq.Task, opts ...asynq.Op
return info, nil
}

// GetTaskInfo returns the task info for the given task ID in a queue.
func (c *Client) GetTaskInfo(queue string, id string) (*asynq.TaskInfo, error) {
// TaskInfo returns the task info for the given task ID in a queue.
func (c *Client) TaskInfo(queue string, id string) (*asynq.TaskInfo, error) {
return c.inspector.GetTaskInfo(queue, id)
}

Expand All @@ -100,7 +100,7 @@ func (c *Client) Ping(ctx context.Context) error {
case <-ctx.Done():
return errors.Join(ErrReceiveTask, ctx.Err())
default:
if info, err = c.GetTaskInfo(info.Queue, info.ID); err != nil {
if info, err = c.TaskInfo(info.Queue, info.ID); err != nil {
return errors.Join(ErrReceiveTask, err)
}
}
Expand Down
4 changes: 2 additions & 2 deletions internal/queue/client_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (s *AsynqClientIntegrationTestSuite) TestEnqueue() {
s.Assert().Equal(asynq.TaskStatePending, info.State)
}

func (s *AsynqClientIntegrationTestSuite) TestGetTaskInfo() {
func (s *AsynqClientIntegrationTestSuite) TestTaskInfo() {
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()

Expand All @@ -96,7 +96,7 @@ func (s *AsynqClientIntegrationTestSuite) TestGetTaskInfo() {

for info.State != asynq.TaskStateCompleted {
s.Require().NoError(ctx.Err())
info, err = s.client.GetTaskInfo(info.Queue, info.ID)
info, err = s.client.TaskInfo(info.Queue, info.ID)
s.Require().NoError(err)
}

Expand Down
4 changes: 2 additions & 2 deletions internal/repository/assignment.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
type AssignmentRepository interface {
Create(ctx context.Context, assignment *model.Assignment) error
Get(ctx context.Context, id model.ID) (*model.Assignment, error)
GetByUser(ctx context.Context, userID model.ID, offset, limit int) ([]*model.Assignment, error)
GetByResource(ctx context.Context, resourceID model.ID, offset, limit int) ([]*model.Assignment, error)
FindByResource(ctx context.Context, resourceID model.ID, offset, limit int) ([]*model.Assignment, error)
FindByUser(ctx context.Context, userID model.ID, offset, limit int) ([]*model.Assignment, error)
Delete(ctx context.Context, id model.ID) error
}
2 changes: 1 addition & 1 deletion internal/repository/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
type DocumentRepository interface {
Create(ctx context.Context, belongsTo model.ID, document *model.Document) error
Get(ctx context.Context, id model.ID) (*model.Document, error)
GetByCreator(ctx context.Context, createdBy model.ID, offset, limit int) ([]*model.Document, error)
FindByCreator(ctx context.Context, createdBy model.ID, offset, limit int) ([]*model.Document, error)
GetAllBelongsTo(ctx context.Context, belongsTo model.ID, offset, limit int) ([]*model.Document, error)
Update(ctx context.Context, id model.ID, patch map[string]any) (*model.Document, error)
Delete(ctx context.Context, id model.ID) error
Expand Down
4 changes: 2 additions & 2 deletions internal/repository/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
type IssueRepository interface {
Create(ctx context.Context, project model.ID, issue *model.Issue) error
Get(ctx context.Context, id model.ID) (*model.Issue, error)
GetAllForProject(ctx context.Context, projectID model.ID, offset, limit int) ([]*model.Issue, error)
GetAllForIssue(ctx context.Context, issueID model.ID, offset, limit int) ([]*model.Issue, error)
FindAllForProject(ctx context.Context, projectID model.ID, offset, limit int) ([]*model.Issue, error)
FindAllForIssue(ctx context.Context, issueID model.ID, offset, limit int) ([]*model.Issue, error)
AddWatcher(ctx context.Context, issue model.ID, user model.ID) error
GetWatchers(ctx context.Context, issue model.ID) ([]*model.User, error)
RemoveWatcher(ctx context.Context, issue model.ID, user model.ID) error
Expand Down
4 changes: 2 additions & 2 deletions internal/repository/neo4j/assignment.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (r *AssignmentRepository) Get(ctx context.Context, id model.ID) (*model.Ass
return assignment, nil
}

func (r *AssignmentRepository) GetByUser(ctx context.Context, userID model.ID, offset, limit int) ([]*model.Assignment, error) {
func (r *AssignmentRepository) FindByUser(ctx context.Context, userID model.ID, offset, limit int) ([]*model.Assignment, error) {
ctx, span := r.tracer.Start(ctx, "repository.neo4j.AssignmentRepository/GetByUser")
defer span.End()

Expand All @@ -129,7 +129,7 @@ func (r *AssignmentRepository) GetByUser(ctx context.Context, userID model.ID, o
return assignments, nil
}

func (r *AssignmentRepository) GetByResource(ctx context.Context, resourceID model.ID, offset, limit int) ([]*model.Assignment, error) {
func (r *AssignmentRepository) FindByResource(ctx context.Context, resourceID model.ID, offset, limit int) ([]*model.Assignment, error) {
ctx, span := r.tracer.Start(ctx, "repository.neo4j.AssignmentRepository/GetByResource")
defer span.End()

Expand Down
16 changes: 8 additions & 8 deletions internal/repository/neo4j/assignment_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,19 @@ func (s *AssignmentRepositoryIntegrationTestSuite) TestGetByUser() {
reviewer := testModel.NewAssignment(s.testUser.ID, s.testDoc.ID, model.AssignmentKindReviewer)
s.Require().NoError(s.AssignmentRepo.Create(context.Background(), reviewer))

assignments, err := s.AssignmentRepo.GetByUser(context.Background(), s.testUser.ID, 0, 10)
assignments, err := s.AssignmentRepo.FindByUser(context.Background(), s.testUser.ID, 0, 10)
s.Require().NoError(err)
s.Assert().Len(assignments, 2)

assignments, err = s.AssignmentRepo.GetByUser(context.Background(), s.testUser.ID, 0, 1)
assignments, err = s.AssignmentRepo.FindByUser(context.Background(), s.testUser.ID, 0, 1)
s.Require().NoError(err)
s.Assert().Len(assignments, 1)

assignments, err = s.AssignmentRepo.GetByUser(context.Background(), s.testUser.ID, 1, 1)
assignments, err = s.AssignmentRepo.FindByUser(context.Background(), s.testUser.ID, 1, 1)
s.Require().NoError(err)
s.Assert().Len(assignments, 1)

assignments, err = s.AssignmentRepo.GetByUser(context.Background(), s.testUser.ID, 2, 1)
assignments, err = s.AssignmentRepo.FindByUser(context.Background(), s.testUser.ID, 2, 1)
s.Require().NoError(err)
s.Assert().Len(assignments, 0)
}
Expand All @@ -102,19 +102,19 @@ func (s *AssignmentRepositoryIntegrationTestSuite) TestGetByResource() {
reviewer := testModel.NewAssignment(s.testUser.ID, s.testDoc.ID, model.AssignmentKindReviewer)
s.Require().NoError(s.AssignmentRepo.Create(context.Background(), reviewer))

assignments, err := s.AssignmentRepo.GetByResource(context.Background(), s.testDoc.ID, 0, 10)
assignments, err := s.AssignmentRepo.FindByResource(context.Background(), s.testDoc.ID, 0, 10)
s.Require().NoError(err)
s.Assert().Len(assignments, 2)

assignments, err = s.AssignmentRepo.GetByResource(context.Background(), s.testDoc.ID, 0, 1)
assignments, err = s.AssignmentRepo.FindByResource(context.Background(), s.testDoc.ID, 0, 1)
s.Require().NoError(err)
s.Assert().Len(assignments, 1)

assignments, err = s.AssignmentRepo.GetByResource(context.Background(), s.testDoc.ID, 1, 1)
assignments, err = s.AssignmentRepo.FindByResource(context.Background(), s.testDoc.ID, 1, 1)
s.Require().NoError(err)
s.Assert().Len(assignments, 1)

assignments, err = s.AssignmentRepo.GetByResource(context.Background(), s.testDoc.ID, 2, 1)
assignments, err = s.AssignmentRepo.FindByResource(context.Background(), s.testDoc.ID, 2, 1)
s.Require().NoError(err)
s.Assert().Len(assignments, 0)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/repository/neo4j/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ func (r *DocumentRepository) Get(ctx context.Context, id model.ID) (*model.Docum
return doc, nil
}

func (r *DocumentRepository) GetByCreator(ctx context.Context, createdBy model.ID, offset, limit int) ([]*model.Document, error) {
ctx, span := r.tracer.Start(ctx, "repository.neo4j.DocumentRepository/GetByCreator")
func (r *DocumentRepository) FindByCreator(ctx context.Context, createdBy model.ID, offset, limit int) ([]*model.Document, error) {
ctx, span := r.tracer.Start(ctx, "repository.neo4j.DocumentRepository/FindByCreator")
defer span.End()

cypher := `
Expand Down
10 changes: 5 additions & 5 deletions internal/repository/neo4j/document_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,24 @@ func (s *DocumentRepositoryIntegrationTestSuite) TestGet() {
s.Assert().Nil(s.document.UpdatedAt)
}

func (s *DocumentRepositoryIntegrationTestSuite) TestGetByCreator() {
func (s *DocumentRepositoryIntegrationTestSuite) TestFindByCreator() {
s.Require().NoError(s.DocumentRepo.Create(context.Background(), s.testUser.ID, s.document))
s.Require().NoError(s.DocumentRepo.Create(context.Background(), s.testUser.ID, testModel.NewDocument(s.testUser.ID)))
s.Require().NoError(s.DocumentRepo.Create(context.Background(), s.testUser.ID, testModel.NewDocument(s.testUser.ID)))

documents, err := s.DocumentRepo.GetByCreator(context.Background(), s.testUser.ID, 0, 10)
documents, err := s.DocumentRepo.FindByCreator(context.Background(), s.testUser.ID, 0, 10)
s.Require().NoError(err)
s.Assert().Len(documents, 3)

documents, err = s.DocumentRepo.GetByCreator(context.Background(), s.testUser.ID, 1, 2)
documents, err = s.DocumentRepo.FindByCreator(context.Background(), s.testUser.ID, 1, 2)
s.Require().NoError(err)
s.Assert().Len(documents, 2)

documents, err = s.DocumentRepo.GetByCreator(context.Background(), s.testUser.ID, 2, 2)
documents, err = s.DocumentRepo.FindByCreator(context.Background(), s.testUser.ID, 2, 2)
s.Require().NoError(err)
s.Assert().Len(documents, 1)

documents, err = s.DocumentRepo.GetByCreator(context.Background(), s.testUser.ID, 3, 2)
documents, err = s.DocumentRepo.FindByCreator(context.Background(), s.testUser.ID, 3, 2)
s.Require().NoError(err)
s.Assert().Len(documents, 0)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/repository/neo4j/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func (r *IssueRepository) Get(ctx context.Context, id model.ID) (*model.Issue, e
return issue, nil
}

func (r *IssueRepository) GetAllForProject(ctx context.Context, projectID model.ID, offset, limit int) ([]*model.Issue, error) {
func (r *IssueRepository) FindAllForProject(ctx context.Context, projectID model.ID, offset, limit int) ([]*model.Issue, error) {
ctx, span := r.tracer.Start(ctx, "repository.neo4j.IssueRepository/GetAllForProject")
defer span.End()

Expand Down Expand Up @@ -294,7 +294,7 @@ func (r *IssueRepository) GetAllForProject(ctx context.Context, projectID model.
return issues, nil
}

func (r *IssueRepository) GetAllForIssue(ctx context.Context, issueID model.ID, offset, limit int) ([]*model.Issue, error) {
func (r *IssueRepository) FindAllForIssue(ctx context.Context, issueID model.ID, offset, limit int) ([]*model.Issue, error) {
ctx, span := r.tracer.Start(ctx, "repository.neo4j.IssueRepository/GetAllForProject")
defer span.End()

Expand Down
Loading