Quiz: Testing
Test yourself on what you have learned so far.
1
In the provided code, what does the WaitingFor
configuration primarily ensure?
const dbUrl = "postgres://***:***@localhost:%s/mallbots"
s.container, err = testcontainers.GenericContainer(ctx,
testcontainers.GenericContainerRequest{
ContainerRequest: testcontainers.ContainerRequest{
Image: "postgres:12-alpine",
ExposedPorts: []string{"5432/tcp"},
Env: map[string]string{"POSTGRES_PASSWORD": "***",},
Mounts: []testcontainers.ContainerMount{testcontainers.BindMount(initDir,"/docker-entrypoint-initdb.d",),},
WaitingFor: wait.ForSQL(
"5432/tcp",
"pgx",
func(port nat.Port) string {
return fmt.Sprintf(
dbUrl,
port.Port(),
)
},
).Timeout(5 * time.Second),
},
Started: true,
},
)
A)
It waits for the PostgreSQL container to download the necessary files.
B)
It waits for a specific time duration before proceeding with container initialization.
C)
It ensures that the PostgreSQL database is ready to accept requests before proceeding.
D)
It waits for the Docker container to reach a certain memory threshold before continuing.
Question 1 of 60 attempted
Get hands-on with 1400+ tech skills courses.