master
Caj Larsson 3 years ago
parent 9e41b707bf
commit 7274e08b9a

@ -33,6 +33,7 @@ func basicFileOperationContract(fac func() Repository, t *testing.T) {
is.NoErr(err)
is.True(reopened_file != nil)
is.Equal(reopened_file.Size(), int64(len(testdata)))
readback := make([]byte, 128)

@ -115,7 +115,13 @@ func (f Repository) Open(filename string, namespace_ns string) (swampfile.SwampO
return nil, swampfile.ErrNotExists
}
bfd := FileSystemSwampFileData{filename, 0, time.Now(), file}
stat, err := file.Stat()
if err != nil {
return nil, err
}
bfd := FileSystemSwampFileData{filename, stat.Size(), time.Now(), file}
return bfd, nil
}

@ -44,7 +44,6 @@ func (b *Bog) fileHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hi")
return
}
ref := swampfile.FileReference{r.URL.Path, r.Header["User-Agent"][0]}
switch r.Method {
@ -71,6 +70,7 @@ func (b *Bog) fileHandler(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(422)
return
}
b.logger.Info("Recieving file '%s' of size %d from '%s'", ref.Path, size, ref.UserAgent)
err = b.file_service.SaveFile(ref, r.Body, size)

@ -13,20 +13,28 @@ import (
"time"
)
type TestLogger struct{}
func (t TestLogger) Debug(format string, a ...interface{}) {}
func (t TestLogger) Info(format string, a ...interface{}) {}
func (t TestLogger) Warn(format string, a ...interface{}) {}
func TestApplication(t *testing.T) {
is := is.New(t)
logger := TestLogger{}
file_service := dataswamp.NewSwampFileService(
namespace.NewRepository(),
swampfile.NewRepository(),
1000,
time.Hour,
ServerLogger{Debug},
logger,
)
bog := Bog{
router: new(http.ServeMux),
file_service: file_service,
address: "fake",
logger: logger,
}
bog.routes()
req := httptest.NewRequest("POST", "/apath", strings.NewReader("testdata"))

Loading…
Cancel
Save