Documentation
¶
Overview ¶
Package fakegcsserver provides a Testcontainers module for the Fake GCS Server (https://github.com/fsouza/fake-gcs-server), a Google Cloud Storage API emulator for local development and testing. It exposes the GCS JSON API on port 4443 with an in-memory storage backend.
Package fakegcsserver — see package documentation in fakegcsserver.go.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Container ¶
type Container struct {
testcontainers.Container
// contains filtered or unexported fields
}
Container represents the FakeGCSServer container type used in the module.
func Run ¶
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*Container, error)
Run creates an instance of the FakeGCSServer container type.
Example ¶
ExampleRun demonstrates how to start a FakeGCSServer container and retrieve its GCS-compatible storage URL.
package main
import (
"context"
"fmt"
"log"
"github.com/testcontainers/testcontainers-go"
"github.com/testcontainers/testcontainers-go/modules/fakegcsserver"
)
func main() {
// runFakeGCSServerContainer {
ctx := context.Background()
fakegcsserverContainer, err := fakegcsserver.Run(ctx, "fsouza/fake-gcs-server:1.47")
defer func() {
if err := testcontainers.TerminateContainer(fakegcsserverContainer); err != nil {
log.Printf("failed to terminate container: %s", err)
}
}()
if err != nil {
log.Printf("failed to start container: %s", err)
return
}
// }
storageURL, err := fakegcsserverContainer.StorageURL(ctx)
if err != nil {
log.Printf("failed to get storage URL: %s", err)
return
}
fmt.Println(storageURL != "")
}
Output: true
func (*Container) StorageURL ¶
StorageURL returns the GCS-compatible storage URL for the container. The URL is in the form: <scheme>://<host>:<port>/storage/v1 where scheme matches the value passed to WithScheme (default "http").
type Option ¶
type Option func(*options) error
Option is an option for the FakeGCSServer container.
func WithScheme ¶
WithScheme sets the scheme used by the fake-gcs-server. Valid values are "http" (default) and "https".
Note: "-scheme both" is not supported because it requires a second port (default 8000) for HTTP in addition to the HTTPS port (4443) and this module only exposes 4443/tcp.
func (Option) Customize ¶
func (o Option) Customize(*testcontainers.GenericContainerRequest) error
Customize is a NOOP. It's defined to satisfy the testcontainers.ContainerCustomizer interface.