Exemplo n.º 1
0
func NewFileServiceWithFs(registry kit.Registry, dataPath string) *FileService {
	if dataPath == "" {
		panic("Empty data path")
	}

	service := NewFileService(registry)

	res := resources.NewResource(&FileIntId{}, FilesResource{}, true)
	service.SetResource(res)

	fs, err := fs.New(dataPath)
	if err != nil {
		panic(fmt.Sprintf("Could not initialize filesystem backend: %v", err))
	}
	service.AddBackend(fs)

	return service
}
Exemplo n.º 2
0
			// Create bucket first.
			err := backend.CreateBucket("test", nil)
			Expect(err).ToNot(HaveOccurred())

			content := []byte("test content")
			createFile("test", "testfile", content)

			Expect(backend.DeleteFileById("test", "testfile")).ToNot(HaveOccurred())
			Expect(backend.HasFileById("test", "testfile")).To(BeFalse())
		})
	}

	Context("fs Backend", func() {
		BeforeEach(func() {
			err := os.RemoveAll("tmp")
			Expect(err).ToNot(HaveOccurred())

			var err2 error
			backend, err2 = fs.New("tmp")
			Expect(err2).ToNot(HaveOccurred())
		})

		AfterEach(func() {
			os.RemoveAll("tmp")
		})

		testBackend()
	})

})