Documentation
¶
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
}
Container represents the RavenDB 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 RavenDB container type
Example ¶
ExampleRun demonstrates how to create and start a RavenDB container.
package main
import (
"context"
"fmt"
"log"
"github.com/testcontainers/testcontainers-go"
"github.com/testcontainers/testcontainers-go/modules/ravendb"
)
func main() {
// runRavenDBContainer {
ctx := context.Background()
ravendbContainer, err := ravendb.Run(ctx, "ravendb/ravendb:6.0-ubuntu-latest")
defer func() {
if err := testcontainers.TerminateContainer(ravendbContainer); err != nil {
log.Printf("failed to terminate container: %s", err)
}
}()
if err != nil {
log.Printf("failed to start container: %s", err)
return
}
// }
state, err := ravendbContainer.State(ctx)
if err != nil {
log.Printf("failed to get container state: %s", err)
return
}
fmt.Println(state.Running)
}
Output: true
Example (ManagementURL) ¶
ExampleRun_managementURL demonstrates how to retrieve the RavenDB management URL.
package main
import (
"context"
"fmt"
"log"
"github.com/testcontainers/testcontainers-go"
"github.com/testcontainers/testcontainers-go/modules/ravendb"
)
func main() {
ctx := context.Background()
ravendbContainer, err := ravendb.Run(ctx, "ravendb/ravendb:6.0-ubuntu-latest")
defer func() {
if err := testcontainers.TerminateContainer(ravendbContainer); err != nil {
log.Printf("failed to terminate container: %s", err)
}
}()
if err != nil {
log.Printf("failed to start container: %s", err)
return
}
managementURL, err := ravendbContainer.ManagementURL(ctx)
if err != nil {
log.Printf("failed to get management URL: %s", err)
return
}
isHTTP := len(managementURL) > 7 && managementURL[:7] == "http://"
fmt.Println(isHTTP)
}
Output: true
func (*Container) ManagementURL ¶
ManagementURL returns the URL of the RavenDB management interface (Studio UI and REST API). The URL has the format http://<host>:<port>.
Click to show internal directories.
Click to hide internal directories.