From ee9603548defa348ab2f645699e5c3153bf4bfcd Mon Sep 17 00:00:00 2001 From: Jeff Ortel Date: Tue, 17 Oct 2023 12:46:12 -0700 Subject: [PATCH 1/3] :bug: bucket directory header missing. Signed-off-by: Jeff Ortel --- api/bucket.go | 1 + 1 file changed, 1 insertion(+) diff --git a/api/bucket.go b/api/bucket.go index 42d4c0934..f91ca0f51 100644 --- a/api/bucket.go +++ b/api/bucket.go @@ -327,6 +327,7 @@ func (h *BucketOwner) getDir(ctx *gin.Context, input string, filter tar.Filter) return } else { h.Attachment(ctx, pathlib.Base(input)+".tar.gz") + ctx.Writer.Header().Set(Directory, DirectoryExpand) ctx.Status(http.StatusOK) } _ = tarWriter.AddDir(input) From 5964541f594a3aa22213180ec8556acfb2867447 Mon Sep 17 00:00:00 2001 From: Jeff Ortel Date: Tue, 17 Oct 2023 13:28:57 -0700 Subject: [PATCH 2/3] checkpoint Signed-off-by: Jeff Ortel --- api/bucket.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/api/bucket.go b/api/bucket.go index f91ca0f51..20483debd 100644 --- a/api/bucket.go +++ b/api/bucket.go @@ -325,11 +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.Writer.Header().Set(Directory, DirectoryExpand) - ctx.Status(http.StatusOK) } + h.Attachment(ctx, pathlib.Base(input)+".tar.gz") + ctx.Writer.Header().Set(Directory, DirectoryExpand) + ctx.Status(http.StatusOK) _ = tarWriter.AddDir(input) return } From 2d73abc99e127f6721afd73b5f9820940bbc355a Mon Sep 17 00:00:00 2001 From: Jeff Ortel Date: Tue, 17 Oct 2023 14:13:27 -0700 Subject: [PATCH 3/3] Fix tests. Signed-off-by: Jeff Ortel --- test/api/application/bucket_test.go | 14 +++++++++++--- test/api/bucket/sample/sample2.txt | 1 + test/api/task/bucket_test.go | 30 +++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 test/api/bucket/sample/sample2.txt create mode 100644 test/api/task/bucket_test.go diff --git a/test/api/application/bucket_test.go b/test/api/application/bucket_test.go index 1a1739fbb..34e550d84 100644 --- a/test/api/application/bucket_test.go +++ b/test/api/application/bucket_test.go @@ -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" ) @@ -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()) } diff --git a/test/api/bucket/sample/sample2.txt b/test/api/bucket/sample/sample2.txt new file mode 100644 index 000000000..e7169f58d --- /dev/null +++ b/test/api/bucket/sample/sample2.txt @@ -0,0 +1 @@ +The second file. \ No newline at end of file diff --git a/test/api/task/bucket_test.go b/test/api/task/bucket_test.go new file mode 100644 index 000000000..20ee9a309 --- /dev/null +++ b/test/api/task/bucket_test.go @@ -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)) +}