removing unused functions in SimpleFileStore

Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
This commit is contained in:
David Lawrence 2016-04-19 14:51:01 -07:00
parent 64ea94567b
commit 4f58eda1ec
2 changed files with 0 additions and 93 deletions

View File

@ -64,24 +64,6 @@ func (f *SimpleFileStore) Remove(name string) error {
return os.Remove(filePath)
}
// RemoveDir removes the directory identified by name
func (f *SimpleFileStore) RemoveDir(name string) error {
dirPath := filepath.Join(f.baseDir, name)
// Check to see if directory exists
fi, err := os.Stat(dirPath)
if err != nil {
return err
}
// Check to see if it is a directory
if !fi.IsDir() {
return fmt.Errorf("directory not found: %s", name)
}
return os.RemoveAll(dirPath)
}
// Get returns the data given a file name
func (f *SimpleFileStore) Get(name string) ([]byte, error) {
filePath, err := f.GetPath(name)
@ -112,12 +94,6 @@ func (f *SimpleFileStore) ListFiles() []string {
return f.list(f.baseDir)
}
// ListDir lists all the files inside of a directory identified by a name
func (f *SimpleFileStore) ListDir(name string) []string {
fullPath := filepath.Join(f.baseDir, name)
return f.list(fullPath)
}
// list lists all the files in a directory given a full path. Ignores symlinks.
func (f *SimpleFileStore) list(path string) []string {
files := make([]string, 0, 0)

View File

@ -74,39 +74,6 @@ func TestRemoveFile(t *testing.T) {
require.Error(t, err)
}
func TestRemoveDir(t *testing.T) {
testName := "docker.com/diogomonica/"
testExt := ".key"
perms := os.FileMode(0700)
// Temporary directory where test files will be created
tempBaseDir, err := ioutil.TempDir("", "notary-test-")
require.NoError(t, err)
defer os.RemoveAll(tempBaseDir)
// Since we're generating this manually we need to add the extension '.'
expectedFilePath := filepath.Join(tempBaseDir, testName+testExt)
_, err = generateRandomFile(expectedFilePath, perms)
require.NoError(t, err)
// Create our SimpleFileStore
store := &SimpleFileStore{
baseDir: tempBaseDir,
fileExt: testExt,
perms: perms,
}
// Call the RemoveDir function
err = store.RemoveDir(testName)
require.NoError(t, err)
expectedDirectory := filepath.Dir(expectedFilePath)
// Check to see if file exists
_, err = os.Stat(expectedDirectory)
require.Error(t, err)
}
func TestListFiles(t *testing.T) {
testName := "docker.com/notary/certificate"
testExt := "crt"
@ -139,42 +106,6 @@ func TestListFiles(t *testing.T) {
require.Len(t, files, 10)
}
func TestListDir(t *testing.T) {
testName := "docker.com/notary/certificate"
testExt := "crt"
perms := os.FileMode(0755)
// Temporary directory where test files will be created
tempBaseDir, err := ioutil.TempDir("", "notary-test-")
require.NoError(t, err)
defer os.RemoveAll(tempBaseDir)
var expectedFilePath string
// Create 10 randomfiles
for i := 1; i <= 10; i++ {
// Since we're generating this manually we need to add the extension '.'
fileName := fmt.Sprintf("%s-%s.%s", testName, strconv.Itoa(i), testExt)
expectedFilePath = filepath.Join(tempBaseDir, fileName)
_, err = generateRandomFile(expectedFilePath, perms)
require.NoError(t, err)
}
// Create our SimpleFileStore
store := &SimpleFileStore{
baseDir: tempBaseDir,
fileExt: testExt,
perms: perms,
}
// Call the ListDir function
files := store.ListDir("docker.com/")
require.Len(t, files, 10)
files = store.ListDir("docker.com/notary")
require.Len(t, files, 10)
files = store.ListDir("fakedocker.com/")
require.Len(t, files, 0)
}
func TestGetPath(t *testing.T) {
testExt := ".crt"
perms := os.FileMode(0755)