diff --git a/server-go/go.mod b/server-go/go.mod index 7b8a4519..a2fd2bf7 100644 --- a/server-go/go.mod +++ b/server-go/go.mod @@ -6,10 +6,14 @@ require ( github.com/appleboy/gin-jwt/v2 v2.8.0 github.com/fatih/structs v1.1.0 github.com/gin-gonic/gin v1.7.7 + github.com/google/uuid v1.3.0 github.com/jessevdk/go-flags v1.5.0 + github.com/julianshen/gin-limiter v0.0.0-20161123033831-fc39b5e90fe7 + github.com/robfig/cron/v3 v3.0.1 github.com/sirupsen/logrus v1.8.1 github.com/stretchr/testify v1.7.0 github.com/tidwall/gjson v1.14.0 + gocloud.dev v0.24.0 golang.org/x/crypto v0.0.0-20220131195533-30dcbda58838 gorm.io/driver/postgres v1.2.3 gorm.io/gorm v1.22.5 @@ -44,7 +48,6 @@ require ( github.com/golang/protobuf v1.5.2 // indirect github.com/google/go-cmp v0.5.6 // indirect github.com/google/gofuzz v1.1.0 // indirect - github.com/google/uuid v1.3.0 // indirect github.com/google/wire v0.5.0 // indirect github.com/googleapis/gax-go/v2 v2.1.0 // indirect github.com/googleapis/gnostic v0.5.5 // indirect @@ -62,7 +65,6 @@ require ( github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/juju/ratelimit v1.0.1 // indirect - github.com/julianshen/gin-limiter v0.0.0-20161123033831-fc39b5e90fe7 // indirect github.com/leodido/go-urn v1.2.0 // indirect github.com/mattn/go-isatty v0.0.12 // indirect github.com/mattn/go-sqlite3 v1.14.9 // indirect @@ -70,13 +72,11 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/robfig/cron/v3 v3.0.1 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.0 // indirect github.com/ugorji/go/codec v1.1.7 // indirect go.opencensus.io v0.23.0 // indirect - gocloud.dev v0.24.0 // indirect golang.org/x/net v0.0.0-20211209124913-491a49abca63 // indirect golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect golang.org/x/sys v0.0.0-20211029165221-6e7872819dc8 // indirect diff --git a/server-go/storage/rotation.go b/server-go/storage/rotation.go index 1f878503..6c718260 100644 --- a/server-go/storage/rotation.go +++ b/server-go/storage/rotation.go @@ -42,7 +42,6 @@ func (frs *FifoRotationStrategy) GetVersionsThatShouldBeDeletedIfThisVersionUplo return existingVersions[0:1] } -// todo: test reference func NewFifoRotationStrategy(collection *collections.Collection, existingVersions []UploadedVersion) *FifoRotationStrategy { return &FifoRotationStrategy{ collection: collection, diff --git a/server-go/storage/rotation_test.go b/server-go/storage/rotation_test.go index 82be0547..d59c0994 100644 --- a/server-go/storage/rotation_test.go +++ b/server-go/storage/rotation_test.go @@ -1 +1,30 @@ package storage + +import ( + "github.com/riotkit-org/backup-repository/collections" + "github.com/stretchr/testify/assert" + "testing" +) + +func TestNewFifoRotationStrategy_MutationTest(t *testing.T) { + collectionFirst := collections.Collection{} + versionsFirst := []UploadedVersion{ + {Filename: "1.1"}, + } + + collectionSecond := collections.Collection{} + versionsSecond := []UploadedVersion{ + {Filename: "2.1"}, + } + + // one object from factory will not impact second + strategyFirst := NewFifoRotationStrategy(&collectionFirst, versionsFirst) + strategySecond := NewFifoRotationStrategy(&collectionSecond, versionsSecond) + + strategyFirst.collection.Metadata.Name = "first" + strategySecond.collection.Metadata.Name = "second" + + assert.NotEqual(t, collectionFirst.Metadata.Name, collectionSecond.Metadata.Name) + assert.NotEqual(t, strategyFirst, strategySecond) + assert.NotEqual(t, &strategyFirst, &strategySecond) +}