Exemple #1
0
func DB() martini.Handler {
	return func(c martini.Context) {
		var db domain.Database
		db = domain.NewInMemoryDatabase()
		c.MapTo(db, (*domain.Database)(nil))
		c.Next()
	}
}
func TestRecordedPartHasBucketWhenValidSubdomain(t *testing.T) {
	req, _ := http.NewRequest("POST", "http://bucket-us-west.s3.example.com/uploads/path/to/my/object", nil)
	addHeaders(req)
	db := domain.NewInMemoryDatabase()
	controller := &UploadController{}

	_, response := controller.InitiateMultipartUpload(req, db)
	result := GetResultMultipartUploadResult(response)

	upload := db.GetUploadByUploadId(result.UploadId)

	assert.Equal(t, "bucket-us-west", upload.Bucket)
}
func TestInitiateMultipartUploadReturnsAnUploadId(t *testing.T) {

	req, _ := http.NewRequest("POST", "http://bucket-us-west.s3.example.com/uploads/path/to/my/object", nil)
	addHeaders(req)
	db := domain.NewInMemoryDatabase()
	controller := &UploadController{}

	status, response := controller.InitiateMultipartUpload(req, db)
	result := GetResultMultipartUploadResult(response)

	assert.Equal(t, status, 201)
	assert.NotNil(t, result)
	assert.NotNil(t, result.UploadId)
}