@@ -25,7 +25,7 @@ const (
2525func Test_ListInstance (t * testing.T ) {
2626 t .Run ("Simple" , core .Test (& core.TestConfig {
2727 Commands : rdb .GetCommands (),
28- BeforeFunc : createInstance ( "PostgreSQL-12" ),
28+ BeforeFunc : core . BeforeFuncCombine ( fetchLatestEngine ( "PostgreSQL" ), createInstance ( "{{.latestEngine}}" ) ),
2929 Cmd : "scw rdb instance list" ,
3030 Check : core .TestCheckGolden (),
3131 AfterFunc : deleteInstance (),
@@ -35,7 +35,7 @@ func Test_ListInstance(t *testing.T) {
3535func Test_CloneInstance (t * testing.T ) {
3636 t .Run ("Simple" , core .Test (& core.TestConfig {
3737 Commands : rdb .GetCommands (),
38- BeforeFunc : createInstance ( "PostgreSQL-12" ),
38+ BeforeFunc : core . BeforeFuncCombine ( fetchLatestEngine ( "PostgreSQL" ), createInstance ( "{{.latestEngine}}" ) ),
3939 Cmd : "scw rdb instance clone {{ .Instance.ID }} node-type=DB-DEV-M name=foobar --wait" ,
4040 Check : core .TestCheckGolden (),
4141 AfterFunc : deleteInstance (),
@@ -153,7 +153,7 @@ func Test_CreateInstanceInitEndpoints(t *testing.T) {
153153func Test_GetInstance (t * testing.T ) {
154154 t .Run ("Simple" , core .Test (& core.TestConfig {
155155 Commands : rdb .GetCommands (),
156- BeforeFunc : createInstance ( "PostgreSQL-12" ),
156+ BeforeFunc : core . BeforeFuncCombine ( fetchLatestEngine ( "PostgreSQL" ), createInstance ( "{{.latestEngine}}" ) ),
157157 Cmd : "scw rdb instance get {{ .Instance.ID }}" ,
158158 Check : core .TestCheckGolden (),
159159 AfterFunc : deleteInstance (),
@@ -163,7 +163,7 @@ func Test_GetInstance(t *testing.T) {
163163func Test_UpgradeInstance (t * testing.T ) {
164164 t .Run ("Simple" , core .Test (& core.TestConfig {
165165 Commands : rdb .GetCommands (),
166- BeforeFunc : createInstance ( "PostgreSQL-12" ),
166+ BeforeFunc : core . BeforeFuncCombine ( fetchLatestEngine ( "PostgreSQL" ), createInstance ( "{{.latestEngine}}" ) ),
167167 Cmd : "scw rdb instance upgrade {{ .Instance.ID }} node-type=DB-DEV-M --wait" ,
168168 Check : core .TestCheckGolden (),
169169 AfterFunc : deleteInstance (),
@@ -173,7 +173,7 @@ func Test_UpgradeInstance(t *testing.T) {
173173func Test_UpdateInstance (t * testing.T ) {
174174 t .Run ("Update instance name" , core .Test (& core.TestConfig {
175175 Commands : rdb .GetCommands (),
176- BeforeFunc : createInstance ( "PostgreSQL-12" ),
176+ BeforeFunc : core . BeforeFuncCombine ( fetchLatestEngine ( "PostgreSQL" ), createInstance ( "{{.latestEngine}}" ) ),
177177 Cmd : "scw rdb instance update {{ .Instance.ID }} name=foo --wait" ,
178178 Check : core .TestCheckCombine (
179179 func (t * testing.T , ctx * core.CheckFuncCtx ) {
@@ -188,7 +188,7 @@ func Test_UpdateInstance(t *testing.T) {
188188
189189 t .Run ("Update instance tags" , core .Test (& core.TestConfig {
190190 Commands : rdb .GetCommands (),
191- BeforeFunc : createInstance ( "PostgreSQL-12" ),
191+ BeforeFunc : core . BeforeFuncCombine ( fetchLatestEngine ( "PostgreSQL" ), createInstance ( "{{.latestEngine}}" ) ),
192192 Cmd : "scw rdb instance update {{ .Instance.ID }} tags.0=a --wait" ,
193193 Check : core .TestCheckCombine (
194194 func (t * testing.T , ctx * core.CheckFuncCtx ) {
@@ -203,7 +203,7 @@ func Test_UpdateInstance(t *testing.T) {
203203
204204 t .Run ("Set a timezone" , core .Test (& core.TestConfig {
205205 Commands : rdb .GetCommands (),
206- BeforeFunc : createInstance ( "PostgreSQL-12" ),
206+ BeforeFunc : core . BeforeFuncCombine ( fetchLatestEngine ( "PostgreSQL" ), createInstance ( "{{.latestEngine}}" ) ),
207207 Cmd : "scw rdb instance update {{ .Instance.ID }} settings.0.name=timezone settings.0.value=UTC --wait" ,
208208 Check : core .TestCheckCombine (
209209 func (t * testing.T , ctx * core.CheckFuncCtx ) {
@@ -219,7 +219,7 @@ func Test_UpdateInstance(t *testing.T) {
219219
220220 t .Run ("Modify default work_mem from 4 to 8 MB" , core .Test (& core.TestConfig {
221221 Commands : rdb .GetCommands (),
222- BeforeFunc : createInstance ( "PostgreSQL-12" ),
222+ BeforeFunc : core . BeforeFuncCombine ( fetchLatestEngine ( "PostgreSQL" ), createInstance ( "{{.latestEngine}}" ) ),
223223 Cmd : "scw rdb instance update {{ .Instance.ID }} settings.0.name=work_mem settings.0.value=8 --wait" ,
224224 Check : core .TestCheckCombine (
225225 func (t * testing.T , ctx * core.CheckFuncCtx ) {
@@ -236,7 +236,8 @@ func Test_UpdateInstance(t *testing.T) {
236236 t .Run ("Modify 3 settings + add a new one" , core .Test (& core.TestConfig {
237237 Commands : rdb .GetCommands (),
238238 BeforeFunc : core .BeforeFuncCombine (
239- createInstance ("PostgreSQL-12" ),
239+ fetchLatestEngine ("PostgreSQL" ),
240+ createInstance ("{{.latestEngine}}" ),
240241 core .ExecBeforeCmd ("scw rdb instance update {{ .Instance.ID }} settings.0.name=work_mem settings.0.value=8" +
241242 " settings.1.name=max_connections settings.1.value=200" +
242243 " settings.2.name=effective_cache_size settings.2.value=1000" +
@@ -272,7 +273,8 @@ func Test_Connect(t *testing.T) {
272273 Commands : rdb .GetCommands (),
273274 BeforeFunc : core .BeforeFuncCombine (
274275 core .BeforeFuncStoreInMeta ("username" , user ),
275- createInstance ("MySQL-8" ),
276+ fetchLatestEngine ("MySQL" ),
277+ createInstance ("{{.latestEngine}}" ),
276278 ),
277279 Cmd : "scw rdb instance connect {{ .Instance.ID }} username={{ .username }}" ,
278280 Check : core .TestCheckCombine (
@@ -287,8 +289,7 @@ func Test_Connect(t *testing.T) {
287289 Commands : rdb .GetCommands (),
288290 BeforeFunc : core .BeforeFuncCombine (
289291 core .BeforeFuncStoreInMeta ("username" , user ),
290- createInstance ("PostgreSQL-15" ),
291- ),
292+ fetchLatestEngine ("PostgreSQL" ), createInstance ("{{.latestEngine}}" )),
292293 Cmd : "scw rdb instance connect {{ .Instance.ID }} username={{ .username }}" ,
293294 Check : core .TestCheckCombine (
294295 core .TestCheckGolden (),
0 commit comments