Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
feat: #164 added primitive test
Browse files Browse the repository at this point in the history
  • Loading branch information
blackandred committed Feb 18, 2022
1 parent 6110d9b commit a3f53d9
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
8 changes: 4 additions & 4 deletions server-go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -62,21 +65,18 @@ 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
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
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
Expand Down
1 change: 0 additions & 1 deletion server-go/storage/rotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
29 changes: 29 additions & 0 deletions server-go/storage/rotation_test.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit a3f53d9

Please sign in to comment.