test(refactor): cleanup/simplify testcases (#1124)

Signed-off-by: Nicol Draghici <idraghic@cisco.com>
This commit is contained in:
Nicol
2023-01-20 20:01:52 +02:00
committed by GitHub
parent 70a60b4660
commit f0d947809b
9 changed files with 144 additions and 392 deletions
+2 -6
View File
@@ -85,9 +85,7 @@ func TestTLSWithAuth(t *testing.T) {
home := os.Getenv("HOME")
destCertsDir := filepath.Join(home, certsDir1)
if err = test.CopyFiles(sourceCertsDir, destCertsDir); err != nil {
panic(err)
}
test.CopyTestFiles(sourceCertsDir, destCertsDir)
defer os.RemoveAll(destCertsDir)
args := []string{"imagetest", "--name", "dummyImageName", "--url", HOST1}
@@ -167,9 +165,7 @@ func TestTLSWithoutAuth(t *testing.T) {
home := os.Getenv("HOME")
destCertsDir := filepath.Join(home, certsDir1)
if err = test.CopyFiles(sourceCertsDir, destCertsDir); err != nil {
panic(err)
}
test.CopyTestFiles(sourceCertsDir, destCertsDir)
defer os.RemoveAll(destCertsDir)
args := []string{"imagetest"}
+5 -17
View File
@@ -352,10 +352,7 @@ func TestServerCVEResponseGQL(t *testing.T) {
dir := t.TempDir()
err := test.CopyFiles("../../test/data/zot-cve-test", path.Join(dir, "zot-cve-test"))
if err != nil {
panic(err)
}
test.CopyTestFiles("../../test/data/zot-cve-test", path.Join(dir, "zot-cve-test"))
conf.Storage.RootDirectory = dir
trivyConfig := &extconf.TrivyConfig{
@@ -645,10 +642,7 @@ func TestNegativeServerResponse(t *testing.T) {
dir := t.TempDir()
err := test.CopyFiles("../../test/data/zot-cve-test", path.Join(dir, "zot-cve-test"))
if err != nil {
panic(err)
}
test.CopyTestFiles("../../test/data/zot-cve-test", path.Join(dir, "zot-cve-test"))
conf.Storage.RootDirectory = dir
trivyConfig := &extconf.TrivyConfig{
@@ -731,12 +725,9 @@ func TestNegativeServerResponse(t *testing.T) {
dir := t.TempDir()
err := test.CopyFiles("../../test/data/zot-cve-test", path.Join(dir, "zot-cve-test"))
if err != nil {
panic(err)
}
test.CopyTestFiles("../../test/data/zot-cve-test", path.Join(dir, "zot-cve-test"))
err = os.RemoveAll(path.Join(dir, "zot-cve-test/blobs"))
err := os.RemoveAll(path.Join(dir, "zot-cve-test/blobs"))
if err != nil {
panic(err)
}
@@ -818,10 +809,7 @@ func TestServerCVEResponse(t *testing.T) {
dir := t.TempDir()
err := test.CopyFiles("../../test/data/zot-cve-test", path.Join(dir, "zot-cve-test"))
if err != nil {
panic(err)
}
test.CopyTestFiles("../../test/data/zot-cve-test", path.Join(dir, "zot-cve-test"))
conf.Storage.RootDirectory = dir
trivyConfig := &extconf.TrivyConfig{
+2 -5
View File
@@ -1284,12 +1284,9 @@ func TestServerResponseGQLWithoutPermissions(t *testing.T) {
dir := t.TempDir()
err := test.CopyFiles("../../test/data/zot-test", path.Join(dir, "zot-test"))
if err != nil {
panic(err)
}
test.CopyTestFiles("../../test/data/zot-test", path.Join(dir, "zot-test"))
err = os.Chmod(path.Join(dir, "zot-test", "blobs"), 0o000)
err := os.Chmod(path.Join(dir, "zot-test", "blobs"), 0o000)
if err != nil {
panic(err)
}