11//
22// DISCLAIMER
33//
4- // Copyright 2024 ArangoDB GmbH, Cologne, Germany
4+ // Copyright 2024-2025 ArangoDB GmbH, Cologne, Germany
55//
66// Licensed under the Apache License, Version 2.0 (the "License");
77// you may not use this file except in compliance with the License.
@@ -26,7 +26,6 @@ import (
2626 "crypto/rand"
2727 "fmt"
2828 "sort"
29- "strings"
3029 "testing"
3130
3231 "github.com/stretchr/testify/require"
@@ -36,27 +35,8 @@ import (
3635 pbStorageV2 "github.com/arangodb/kube-arangodb/integrations/storage/v2/definition"
3736 "github.com/arangodb/kube-arangodb/pkg/util"
3837 "github.com/arangodb/kube-arangodb/pkg/util/errors"
39- ugrpc "github.com/arangodb/kube-arangodb/pkg/util/grpc"
4038)
4139
42- func listAllFilesHelper (t * testing.T , ctx context.Context , h pbStorageV2.StorageV2Client , prefix string ) []* pbStorageV2.StorageV2Object {
43- var r []* pbStorageV2.StorageV2Object
44-
45- res , err := h .ListObjects (ctx , & pbStorageV2.StorageV2ListObjectsRequest {
46- Path : & pbStorageV2.StorageV2Path {
47- Path : prefix ,
48- },
49- })
50- require .NoError (t , err )
51-
52- require .NoError (t , ugrpc .Recv [* pbStorageV2.StorageV2ListObjectsResponse ](res , func (response * pbStorageV2.StorageV2ListObjectsResponse ) error {
53- r = append (r , response .GetFiles ()... )
54- return nil
55- }))
56-
57- return r
58- }
59-
6040func Test_List (t * testing.T ) {
6141 ctx , c := context .WithCancel (context .Background ())
6242 defer c ()
@@ -163,27 +143,30 @@ func testFileListing(t *testing.T, ctx context.Context, h pbStorageV2.StorageV2C
163143 })
164144
165145 t .Run ("List" , func (t * testing.T ) {
166- revcFiles := listAllFilesHelper (t , ctx , h , prefix )
146+ revcFiles , err := pbStorageV2 .List (ctx , h , prefix )
147+ require .NoError (t , err )
167148
168149 require .Len (t , revcFiles , len (files ))
169150
170151 for id := range files {
171- require .EqualValues (t , strings . TrimPrefix ( files [id ], prefix ) , revcFiles [id ].GetPath ().GetPath ())
152+ require .EqualValues (t , files [id ], revcFiles [id ].GetPath ().GetPath ())
172153 require .EqualValues (t , revcFiles [id ].GetInfo ().GetSize (), len (data ))
173154 }
174155 })
175156
176157 t .Run ("ListSubFolder" , func (t * testing.T ) {
177- revcFiles := listAllFilesHelper (t , ctx , h , fmt .Sprintf ("%spath0000/" , prefix ))
158+ revcFiles , err := pbStorageV2 .List (ctx , h , fmt .Sprintf ("%spath0000/" , prefix ))
159+ require .NoError (t , err )
178160
179161 require .Len (t , revcFiles , 1 )
180162
181- require .EqualValues (t , " file" , revcFiles [0 ].GetPath ().GetPath ())
163+ require .EqualValues (t , fmt . Sprintf ( "%spath0000/ file", prefix ) , revcFiles [0 ].GetPath ().GetPath ())
182164 require .EqualValues (t , len (data ), revcFiles [0 ].GetInfo ().GetSize ())
183165 })
184166
185167 t .Run ("ListMisSubFolder" , func (t * testing.T ) {
186- revcFiles := listAllFilesHelper (t , ctx , h , fmt .Sprintf ("%snon-existent/" , prefix ))
168+ revcFiles , err := pbStorageV2 .List (ctx , h , fmt .Sprintf ("%snon-existent/" , prefix ))
169+ require .NoError (t , err )
187170
188171 require .Len (t , revcFiles , 0 )
189172 })
@@ -281,7 +264,8 @@ func testS3BucketFileHandling(t *testing.T, ctx context.Context, h pbStorageV2.S
281264 })
282265
283266 t .Run ("List Objects" , func (t * testing.T ) {
284- revcFiles := listAllFilesHelper (t , ctx , h , prefix )
267+ revcFiles , err := pbStorageV2 .List (ctx , h , "/" )
268+ require .NoError (t , err )
285269
286270 t .Logf ("Size: %d" , len (revcFiles ))
287271 })
0 commit comments