func TestCacheArchiverForIfNoFileDefined(t *testing.T) { helpers.MakeFatalToPanic() cmd := CacheArchiverCommand{} assert.Panics(t, func() { cmd.Execute(nil) }) }
func TestCacheExtractorRemoteServer(t *testing.T) { ts := httptest.NewServer(http.HandlerFunc(testServeCache)) defer ts.Close() defer os.Remove(cacheExtractorArchive) defer os.Remove(cacheExtractorTestArchivedFile) os.Remove(cacheExtractorArchive) os.Remove(cacheExtractorTestArchivedFile) helpers.MakeFatalToPanic() cmd := CacheExtractorCommand{ File: cacheExtractorArchive, URL: ts.URL + "/cache.zip", } assert.NotPanics(t, func() { cmd.Execute(nil) }) _, err := os.Stat(cacheExtractorTestArchivedFile) assert.NoError(t, err) os.Chtimes(cacheExtractorArchive, time.Now().Add(time.Hour), time.Now().Add(time.Hour)) assert.NotPanics(t, func() { cmd.Execute(nil) }, "archive is up to date") }
func TestArtifactsUploaderRequirements(t *testing.T) { helpers.MakeFatalToPanic() cmd := ArtifactsUploaderCommand{} assert.Panics(t, func() { cmd.Execute(nil) }) }
func TestCacheExtractorForNotExistingFile(t *testing.T) { helpers.MakeFatalToPanic() cmd := CacheExtractorCommand{ File: "/../../../test.zip", } assert.NotPanics(t, func() { cmd.Execute(nil) }) }
func TestCacheExtractorForInvalidArchive(t *testing.T) { helpers.MakeFatalToPanic() ioutil.WriteFile(cacheExtractorArchive, nil, 0600) defer os.Remove(cacheExtractorArchive) cmd := CacheExtractorCommand{ File: cacheExtractorArchive, } assert.Panics(t, func() { cmd.Execute(nil) }) }
func TestCacheArchiverRemoteServerDoesntFailOnInvalidServer(t *testing.T) { helpers.MakeFatalToPanic() os.Remove(cacheExtractorArchive) cmd := CacheArchiverCommand{ File: cacheExtractorArchive, URL: "http://localhost:65333/cache.zip", } assert.NotPanics(t, func() { cmd.Execute(nil) }) _, err := os.Stat(cacheExtractorTestArchivedFile) assert.Error(t, err) }
func TestCacheArchiverRemoteServe(t *testing.T) { ts := httptest.NewServer(http.HandlerFunc(testCacheUploadHandler)) defer ts.Close() helpers.MakeFatalToPanic() os.Remove(cacheExtractorArchive) cmd := CacheArchiverCommand{ File: cacheExtractorArchive, URL: ts.URL + "/cache.zip", } assert.NotPanics(t, func() { cmd.Execute(nil) }) }
func TestCacheExtractorRemoteServerNotFound(t *testing.T) { ts := httptest.NewServer(http.HandlerFunc(testServeCache)) defer ts.Close() helpers.MakeFatalToPanic() cmd := CacheExtractorCommand{ File: "non-existing-test.zip", URL: ts.URL + "/invalid-file.zip", } assert.NotPanics(t, func() { cmd.Execute(nil) }) _, err := os.Stat(cacheExtractorTestArchivedFile) assert.Error(t, err) }