Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
leo-scalingo committed Nov 21, 2024
1 parent 6da687f commit ae3124d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions mongo/document/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ var _ Validable = &Base{}
func Create(ctx context.Context, collectionName string, doc document) error {
return save(ctx, collectionName, doc, func(ctx context.Context, collectionName string, doc document) error {
log := logger.Get(ctx)
//nolint contextcheck
c := mongo.Session(log).Clone().DB("").C(collectionName)
defer c.Database.Session.Close()
log.WithFields(logrus.Fields{
Expand All @@ -82,6 +83,7 @@ func Create(ctx context.Context, collectionName string, doc document) error {
func Save(ctx context.Context, collectionName string, doc document) error {
return save(ctx, collectionName, doc, func(ctx context.Context, collectionName string, doc document) error {
log := logger.Get(ctx)
//nolint contextcheck
c := mongo.Session(log).Clone().DB("").C(collectionName)
defer c.Database.Session.Close()
log.Debugf("save '%v'", collectionName)
Expand All @@ -93,6 +95,7 @@ func Save(ctx context.Context, collectionName string, doc document) error {
func Update(ctx context.Context, collectionName string, update bson.M, doc document) error {
return save(ctx, collectionName, doc, func(ctx context.Context, collectionName string, doc document) error {
log := logger.Get(ctx)
//nolint contextcheck
c := mongo.Session(log).Clone().DB("").C(collectionName)
defer c.Database.Session.Close()

Expand Down
9 changes: 5 additions & 4 deletions mongo/document/document_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import (
"context"
"testing"

"github.com/Scalingo/go-utils/errors/v2"
"github.com/Scalingo/go-utils/logger"
"github.com/Scalingo/go-utils/mongo"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gopkg.in/mgo.v2"

"github.com/Scalingo/go-utils/errors/v2"
"github.com/Scalingo/go-utils/logger"
"github.com/Scalingo/go-utils/mongo"
)

type unvalidatedDocument struct {
Expand All @@ -23,7 +24,7 @@ type validatedDocument struct {
Valid bool `bson:"valid" json:"valid"`
}

func (d *validatedDocument) Validate(ctx context.Context) *errors.ValidationErrors {
func (d *validatedDocument) Validate(_ context.Context) *errors.ValidationErrors {
verr := errors.NewValidationErrorsBuilder()
if !d.Valid {
verr.Set("valid", "must be true")
Expand Down

0 comments on commit ae3124d

Please sign in to comment.