Skip to content

Commit ec98813

Browse files
authored
feat: add capability to configure clickhouse version (#400)
1 parent 9dde2a1 commit ec98813

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

testing/platform/clickhousetesting/clickhouse.go

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,17 @@ func (s *Server) NewDatabase(t TestingT) *Database {
6464
}
6565
}
6666

67-
func CreateServer(pool *docker.Pool) *Server {
67+
func CreateServer(pool *docker.Pool, opts ...ServerOption) *Server {
68+
69+
serverOptions := ServerOptions{}
70+
for _, opt := range append(defaultOptions, opts...) {
71+
opt(&serverOptions)
72+
}
73+
6874
resource := pool.Run(docker.Configuration{
6975
RunOptions: &dockertest.RunOptions{
7076
Repository: "clickhouse/clickhouse-server",
71-
Tag: "25.2-alpine",
77+
Tag: serverOptions.Version,
7278
Env: []string{"CLICKHOUSE_PASSWORD=password"},
7379
},
7480
CheckFn: func(ctx context.Context, resource *dockertest.Resource) error {
@@ -103,3 +109,19 @@ type Database struct {
103109
func (d *Database) ConnString() string {
104110
return d.url
105111
}
112+
113+
type ServerOptions struct {
114+
Version string
115+
}
116+
117+
type ServerOption func(options *ServerOptions)
118+
119+
func WithVersion(version string) ServerOption {
120+
return func(options *ServerOptions) {
121+
options.Version = version
122+
}
123+
}
124+
125+
var defaultOptions = []ServerOption{
126+
WithVersion("25.2-alpine"),
127+
}

0 commit comments

Comments
 (0)