diff --git a/docs/modules/influxdb.md b/docs/modules/influxdb.md index d324d41d7b..3ba950aefe 100644 --- a/docs/modules/influxdb.md +++ b/docs/modules/influxdb.md @@ -83,3 +83,6 @@ This function is a simple helper to return a URL to the container, using the def Please check the existence of two methods: `ConnectionUrl` and `MustConnectionUrl`. The latter is used to avoid the need to handle errors, while the former is used to return the URL and the error. `MustConnectionUrl` will panic if an error occurs. + +!!!info + The `ConnectionUrl` and `MustConnectionUrl` methods only support HTTP connections at the moment. diff --git a/modules/influxdb/influxdb.go b/modules/influxdb/influxdb.go index 67bc602435..5880715fcd 100644 --- a/modules/influxdb/influxdb.go +++ b/modules/influxdb/influxdb.go @@ -84,15 +84,15 @@ func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomize return &InfluxDbContainer{container}, nil } -func (c *InfluxDbContainer) MustConnectionUrl(ctx context.Context, tls bool) string { - connectionString, err := c.ConnectionUrl(ctx, tls) +func (c *InfluxDbContainer) MustConnectionUrl(ctx context.Context) string { + connectionString, err := c.ConnectionUrl(ctx) if err != nil { panic(err) } return connectionString } -func (c *InfluxDbContainer) ConnectionUrl(ctx context.Context, tls bool) (string, error) { +func (c *InfluxDbContainer) ConnectionUrl(ctx context.Context) (string, error) { containerPort, err := c.MappedPort(ctx, "8086/tcp") if err != nil { return "", err @@ -103,12 +103,7 @@ func (c *InfluxDbContainer) ConnectionUrl(ctx context.Context, tls bool) (string return "", err } - scheme := "http" - if tls { - scheme = "https" - } - - return fmt.Sprintf("%s://%s:%s", scheme, host, containerPort.Port()), nil + return fmt.Sprintf("http://%s:%s", host, containerPort.Port()), nil } func WithUsername(username string) testcontainers.CustomizeRequestOption { diff --git a/modules/influxdb/influxdb_test.go b/modules/influxdb/influxdb_test.go index f757d7afa1..f80afc1cd6 100644 --- a/modules/influxdb/influxdb_test.go +++ b/modules/influxdb/influxdb_test.go @@ -75,7 +75,7 @@ func TestWithInitDb(t *testing.T) { } cli, err := influxclient.NewHTTPClient(influxclient.HTTPConfig{ - Addr: influxDbContainer.MustConnectionUrl(ctx, false), + Addr: influxDbContainer.MustConnectionUrl(ctx), }) require.NoError(t, err) defer cli.Close() @@ -112,7 +112,7 @@ func TestWithConfigFile(t *testing.T) { /// influxConnectionUrl { cli, err := influxclient.NewHTTPClient(influxclient.HTTPConfig{ - Addr: influxDbContainer.MustConnectionUrl(context.Background(), false), + Addr: influxDbContainer.MustConnectionUrl(context.Background()), }) // } require.NoError(t, err)