mirror of
https://github.com/project-zot/zot.git
synced 2024-12-23 22:27:35 -05:00
6c293719e3
currently different subpaths can only point to same root directory only when one or both of the storage config does not enable dedupe different subpath should be able to point to same root directory and in that case their storage config should be same i.e GC,Dedupe, GC delay and GC interval Signed-off-by: Shivam Mishra <shimish2@cisco.com>
67 lines
1.7 KiB
Go
67 lines
1.7 KiB
Go
package config_test
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
"zotregistry.io/zot/pkg/api/config"
|
|
)
|
|
|
|
func TestConfig(t *testing.T) {
|
|
Convey("Test config utils", t, func() {
|
|
firstStorageConfig := config.StorageConfig{
|
|
GC: true, Dedupe: true,
|
|
GCDelay: 1 * time.Minute, GCInterval: 1 * time.Hour,
|
|
}
|
|
secondStorageConfig := config.StorageConfig{
|
|
GC: true, Dedupe: true,
|
|
GCDelay: 1 * time.Minute, GCInterval: 1 * time.Hour,
|
|
}
|
|
|
|
So(firstStorageConfig.ParamsEqual(secondStorageConfig), ShouldBeTrue)
|
|
|
|
firstStorageConfig.GC = false
|
|
|
|
So(firstStorageConfig.ParamsEqual(secondStorageConfig), ShouldBeFalse)
|
|
|
|
firstStorageConfig.GC = true
|
|
firstStorageConfig.Dedupe = false
|
|
|
|
So(firstStorageConfig.ParamsEqual(secondStorageConfig), ShouldBeFalse)
|
|
|
|
firstStorageConfig.Dedupe = true
|
|
firstStorageConfig.GCDelay = 2 * time.Minute
|
|
|
|
So(firstStorageConfig.ParamsEqual(secondStorageConfig), ShouldBeFalse)
|
|
|
|
firstStorageConfig.GCDelay = 1 * time.Minute
|
|
firstStorageConfig.GCInterval = 2 * time.Hour
|
|
|
|
So(firstStorageConfig.ParamsEqual(secondStorageConfig), ShouldBeFalse)
|
|
|
|
firstStorageConfig.GCInterval = 1 * time.Hour
|
|
|
|
So(firstStorageConfig.ParamsEqual(secondStorageConfig), ShouldBeTrue)
|
|
|
|
isSame, err := config.SameFile("test-config", "test")
|
|
So(err, ShouldNotBeNil)
|
|
So(isSame, ShouldBeFalse)
|
|
|
|
dir1 := t.TempDir()
|
|
|
|
isSame, err = config.SameFile(dir1, "test")
|
|
So(err, ShouldNotBeNil)
|
|
So(isSame, ShouldBeFalse)
|
|
|
|
dir2 := t.TempDir()
|
|
|
|
isSame, err = config.SameFile(dir1, dir2)
|
|
So(err, ShouldBeNil)
|
|
So(isSame, ShouldBeFalse)
|
|
|
|
isSame, err = config.SameFile(dir1, dir1)
|
|
So(err, ShouldBeNil)
|
|
So(isSame, ShouldBeTrue)
|
|
})
|
|
}
|