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() {
|
||||
exists := common.DirExists("testdir")
|
||||
So(exists, ShouldBeFalse)
|
||||
tempDir := t.TempDir()
|
||||
|
||||
file, err := os.Create("file.txt")
|
||||
file, err := os.Create(path.Join(tempDir, "file.txt"))
|
||||
So(err, ShouldBeNil)
|
||||
isDir := common.DirExists(file.Name())
|
||||
So(isDir, ShouldBeFalse)
|
||||
|
|
|
@ -42,7 +42,6 @@ import (
|
|||
const (
|
||||
username = "test"
|
||||
passphrase = "test"
|
||||
testDir = "../../../../test/data"
|
||||
)
|
||||
|
||||
type CveResult struct {
|
||||
|
@ -373,8 +372,6 @@ func TestImageFormat(t *testing.T) {
|
|||
|
||||
func TestCVESearchDisabled(t *testing.T) {
|
||||
Convey("Test with CVE search disabled", t, func() {
|
||||
dbDir := testDir
|
||||
|
||||
port := GetFreePort()
|
||||
baseURL := GetBaseURL(port)
|
||||
conf := config.New()
|
||||
|
@ -388,6 +385,8 @@ func TestCVESearchDisabled(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
dbDir, err := testSetup(t)
|
||||
So(err, ShouldBeNil)
|
||||
conf.Storage.RootDirectory = dbDir
|
||||
defaultVal := true
|
||||
searchConfig := &extconf.SearchConfig{
|
||||
|
@ -748,15 +747,9 @@ func TestHTTPOptionsResponse(t *testing.T) {
|
|||
|
||||
ctlr := api.NewController(conf)
|
||||
|
||||
firstDir, err := os.MkdirTemp("", "oci-repo-test")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
firstDir := t.TempDir()
|
||||
|
||||
secondDir, err := os.MkdirTemp("", "oci-repo-test")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
secondDir := t.TempDir()
|
||||
defer os.RemoveAll(firstDir)
|
||||
defer os.RemoveAll(secondDir)
|
||||
|
||||
|
|
|
@ -273,10 +273,7 @@ func TestDigestSearchHTTPSubPaths(t *testing.T) {
|
|||
|
||||
ctlr := api.NewController(conf)
|
||||
|
||||
globalDir, err := os.MkdirTemp("", "digest_test")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
globalDir := t.TempDir()
|
||||
defer os.RemoveAll(globalDir)
|
||||
|
||||
ctlr.Config.Storage.RootDirectory = globalDir
|
||||
|
|
|
@ -742,10 +742,8 @@ func TestConfigReloader(t *testing.T) {
|
|||
|
||||
destConfig.HTTP.Port = destPort
|
||||
|
||||
destDir, err := os.MkdirTemp("", "oci-dest-repo-test")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
// change
|
||||
destDir := t.TempDir()
|
||||
|
||||
defer os.RemoveAll(destDir)
|
||||
|
||||
|
@ -3928,8 +3926,7 @@ func TestSyncSignaturesDiff(t *testing.T) {
|
|||
So(err, ShouldBeNil)
|
||||
|
||||
defer func() { _ = os.Chdir(cwd) }()
|
||||
tdir, err := os.MkdirTemp("", "sigs")
|
||||
So(err, ShouldBeNil)
|
||||
tdir := t.TempDir()
|
||||
|
||||
_ = os.Chdir(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
|
||||
So(os.RemoveAll(tdir), ShouldBeNil)
|
||||
tdir, err = os.MkdirTemp("", "sigs")
|
||||
So(err, ShouldBeNil)
|
||||
tdir = t.TempDir()
|
||||
defer os.RemoveAll(tdir)
|
||||
_ = os.Chdir(tdir)
|
||||
generateKeyPairs(tdir)
|
||||
|
|
Loading…
Add table
Reference in a new issue