Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Bucket getdir #525

Merged
merged 3 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions api/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,10 @@ func (h *BucketOwner) getDir(ctx *gin.Context, input string, filter tar.Filter)
if err != nil {
_ = ctx.Error(err)
return
} else {
h.Attachment(ctx, pathlib.Base(input)+".tar.gz")
ctx.Status(http.StatusOK)
}
h.Attachment(ctx, pathlib.Base(input)+".tar.gz")
ctx.Writer.Header().Set(Directory, DirectoryExpand)
Copy link
Contributor Author

@jortel jortel Oct 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hint: Add header ^

ctx.Status(http.StatusOK)
_ = tarWriter.AddDir(input)
return
}
Expand Down
14 changes: 11 additions & 3 deletions test/api/application/bucket_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package application

import (
"io/ioutil"
"os"
"testing"

"github.com/konveyor/tackle2-hub/api"
"github.com/konveyor/tackle2-hub/binding"
"github.com/konveyor/tackle2-hub/test/assert"
)

Expand All @@ -16,7 +16,15 @@ func TestApplicationBucket(t *testing.T) {
assert.Must(t, Application.Create(&application))

// Get the bucket to check if it was created.
err := Client.BucketGet(binding.Path(api.BucketRoot).Inject(binding.Params{api.ID: application.Bucket.ID}), "/dev/null")
destDir, err := ioutil.TempDir("", "destDir")
if err != nil {
t.Errorf(err.Error())
}
defer func() {
_ = os.RemoveAll(destDir)
}()
bucket := RichClient.Application.Bucket(application.ID)
err = bucket.Get("", destDir)
if err != nil {
t.Errorf(err.Error())
}
Expand Down
1 change: 1 addition & 0 deletions test/api/bucket/sample/sample2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The second file.
30 changes: 30 additions & 0 deletions test/api/task/bucket_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package task

import (
"io/ioutil"
"os"
"testing"

"github.com/konveyor/tackle2-hub/test/assert"
)

func TestTaskBucket(t *testing.T) {
task := Windup
// Create the application.
assert.Must(t, Task.Create(&task))
// Get the bucket to check if it was created.
destDir, err := ioutil.TempDir("", "destDir")
if err != nil {
t.Errorf(err.Error())
}
defer func() {
_ = os.RemoveAll(destDir)
}()
bucket := RichClient.Task.Bucket(task.ID)
err = bucket.Get("", destDir)
if err != nil {
t.Errorf(err.Error())
}
// Clean the application.
assert.Must(t, Task.Delete(task.ID))
}
Loading