mirror of
https://github.com/project-zot/zot.git
synced 2025-02-17 23:45:36 -05:00
fix(test): update the zot tests not to use test/data as rootDir (use a temporary folder instead) (#1162)
Signed-off-by: Nicol Draghici <idraghic@cisco.com>
This commit is contained in:
parent
863d057e43
commit
ba3f6f7492
4 changed files with 11 additions and 24 deletions
|
@ -42,8 +42,9 @@ func TestCommon(t *testing.T) {
|
||||||
Convey("test dirExists()", t, func() {
|
Convey("test dirExists()", t, func() {
|
||||||
exists := common.DirExists("testdir")
|
exists := common.DirExists("testdir")
|
||||||
So(exists, ShouldBeFalse)
|
So(exists, ShouldBeFalse)
|
||||||
|
tempDir := t.TempDir()
|
||||||
|
|
||||||
file, err := os.Create("file.txt")
|
file, err := os.Create(path.Join(tempDir, "file.txt"))
|
||||||
So(err, ShouldBeNil)
|
So(err, ShouldBeNil)
|
||||||
isDir := common.DirExists(file.Name())
|
isDir := common.DirExists(file.Name())
|
||||||
So(isDir, ShouldBeFalse)
|
So(isDir, ShouldBeFalse)
|
||||||
|
|
|
@ -42,7 +42,6 @@ import (
|
||||||
const (
|
const (
|
||||||
username = "test"
|
username = "test"
|
||||||
passphrase = "test"
|
passphrase = "test"
|
||||||
testDir = "../../../../test/data"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type CveResult struct {
|
type CveResult struct {
|
||||||
|
@ -373,8 +372,6 @@ func TestImageFormat(t *testing.T) {
|
||||||
|
|
||||||
func TestCVESearchDisabled(t *testing.T) {
|
func TestCVESearchDisabled(t *testing.T) {
|
||||||
Convey("Test with CVE search disabled", t, func() {
|
Convey("Test with CVE search disabled", t, func() {
|
||||||
dbDir := testDir
|
|
||||||
|
|
||||||
port := GetFreePort()
|
port := GetFreePort()
|
||||||
baseURL := GetBaseURL(port)
|
baseURL := GetBaseURL(port)
|
||||||
conf := config.New()
|
conf := config.New()
|
||||||
|
@ -388,6 +385,8 @@ func TestCVESearchDisabled(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dbDir, err := testSetup(t)
|
||||||
|
So(err, ShouldBeNil)
|
||||||
conf.Storage.RootDirectory = dbDir
|
conf.Storage.RootDirectory = dbDir
|
||||||
defaultVal := true
|
defaultVal := true
|
||||||
searchConfig := &extconf.SearchConfig{
|
searchConfig := &extconf.SearchConfig{
|
||||||
|
@ -748,15 +747,9 @@ func TestHTTPOptionsResponse(t *testing.T) {
|
||||||
|
|
||||||
ctlr := api.NewController(conf)
|
ctlr := api.NewController(conf)
|
||||||
|
|
||||||
firstDir, err := os.MkdirTemp("", "oci-repo-test")
|
firstDir := t.TempDir()
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
secondDir, err := os.MkdirTemp("", "oci-repo-test")
|
secondDir := t.TempDir()
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(firstDir)
|
defer os.RemoveAll(firstDir)
|
||||||
defer os.RemoveAll(secondDir)
|
defer os.RemoveAll(secondDir)
|
||||||
|
|
||||||
|
|
|
@ -273,10 +273,7 @@ func TestDigestSearchHTTPSubPaths(t *testing.T) {
|
||||||
|
|
||||||
ctlr := api.NewController(conf)
|
ctlr := api.NewController(conf)
|
||||||
|
|
||||||
globalDir, err := os.MkdirTemp("", "digest_test")
|
globalDir := t.TempDir()
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(globalDir)
|
defer os.RemoveAll(globalDir)
|
||||||
|
|
||||||
ctlr.Config.Storage.RootDirectory = globalDir
|
ctlr.Config.Storage.RootDirectory = globalDir
|
||||||
|
|
|
@ -742,10 +742,8 @@ func TestConfigReloader(t *testing.T) {
|
||||||
|
|
||||||
destConfig.HTTP.Port = destPort
|
destConfig.HTTP.Port = destPort
|
||||||
|
|
||||||
destDir, err := os.MkdirTemp("", "oci-dest-repo-test")
|
// change
|
||||||
if err != nil {
|
destDir := t.TempDir()
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
defer os.RemoveAll(destDir)
|
defer os.RemoveAll(destDir)
|
||||||
|
|
||||||
|
@ -3928,8 +3926,7 @@ func TestSyncSignaturesDiff(t *testing.T) {
|
||||||
So(err, ShouldBeNil)
|
So(err, ShouldBeNil)
|
||||||
|
|
||||||
defer func() { _ = os.Chdir(cwd) }()
|
defer func() { _ = os.Chdir(cwd) }()
|
||||||
tdir, err := os.MkdirTemp("", "sigs")
|
tdir := t.TempDir()
|
||||||
So(err, ShouldBeNil)
|
|
||||||
|
|
||||||
_ = os.Chdir(tdir)
|
_ = os.Chdir(tdir)
|
||||||
generateKeyPairs(tdir)
|
generateKeyPairs(tdir)
|
||||||
|
@ -4021,8 +4018,7 @@ func TestSyncSignaturesDiff(t *testing.T) {
|
||||||
|
|
||||||
// now add new signatures to upstream and let sync detect that upstream signatures changed and pull them
|
// now add new signatures to upstream and let sync detect that upstream signatures changed and pull them
|
||||||
So(os.RemoveAll(tdir), ShouldBeNil)
|
So(os.RemoveAll(tdir), ShouldBeNil)
|
||||||
tdir, err = os.MkdirTemp("", "sigs")
|
tdir = t.TempDir()
|
||||||
So(err, ShouldBeNil)
|
|
||||||
defer os.RemoveAll(tdir)
|
defer os.RemoveAll(tdir)
|
||||||
_ = os.Chdir(tdir)
|
_ = os.Chdir(tdir)
|
||||||
generateKeyPairs(tdir)
|
generateKeyPairs(tdir)
|
||||||
|
|
Loading…
Add table
Reference in a new issue