Add Go access test for the DB store and update README
This commit is contained in:
committed by
=Michael Hohn
parent
9270230f08
commit
252859ae18
47
test/dbstore_test.go
Normal file
47
test/dbstore_test.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"context"
|
||||
|
||||
minio "github.com/minio/minio-go/v7"
|
||||
"github.com/minio/minio-go/v7/pkg/credentials"
|
||||
)
|
||||
|
||||
func TestDBListing(t *testing.T) {
|
||||
// Define the MinIO server configuration for access from the host
|
||||
endpoint := "localhost:9000"
|
||||
accessKeyID := "user"
|
||||
secretAccessKey := "mmusty8432"
|
||||
useSSL := false
|
||||
|
||||
// Initialize the MinIO client
|
||||
minioClient, err := minio.New(endpoint, &minio.Options{
|
||||
Creds: credentials.NewStaticV4(accessKeyID, secretAccessKey, ""),
|
||||
Secure: useSSL,
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("Cannot init client")
|
||||
}
|
||||
|
||||
// Define the bucket name
|
||||
bucketName := "qldb"
|
||||
|
||||
// Create a context
|
||||
ctx := context.Background()
|
||||
|
||||
// List all objects in the bucket
|
||||
objectCh := minioClient.ListObjects(ctx, bucketName, minio.ListObjectsOptions{
|
||||
Recursive: true,
|
||||
})
|
||||
|
||||
for object := range objectCh {
|
||||
if object.Err != nil {
|
||||
t.Errorf("Cannot access key listing")
|
||||
}
|
||||
|
||||
t.Logf("Object Key: %s\n", object.Key)
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user