From 60463e3bab9dfa6aae7f379fc77309ab52b1d250 Mon Sep 17 00:00:00 2001 From: Earl Warren <contact@earl-warren.org> Date: Wed, 9 Aug 2023 13:00:36 +0200 Subject: [PATCH] [DB] run all Forgejo migrations in integration tests The tests at tests/integration/migration-test/migration_test.go will not run any Forgejo migration when using the gitea-*.sql.gz files because they do not contain a ForgejoVersion row which is interpreted as a new Forgejo installation for which there is no need for migration. Create a situation by which the ForgejoVersion table exists and has a version of 0 in tests/integration/migration-test/forgejo-v1.19.0.*.sql.gz thus ensuring all Forgejo migrations are run. The forgejo*.sql.gz files do not have any Gitea related records, which will be interpreted by the Gitea migrations as a new installation that does not need any migration. As a consequence the migration tests run when using forgejo-v1.19.0.*.sql.gz are exclusively about Forgejo migrations. (cherry picked from commit ec8003859c920ac05a071ad9b1d9d8af5a694ac0) (cherry picked from commit 697570ff390656930d41bcdc4194aacc5c7a54f4) (cherry picked from commit f041aec17265ca34943f961d9640e60c96c0f24d) --- .../migration-test/forgejo-v1.19.0.mysql.sql.gz | Bin 0 -> 164 bytes .../forgejo-v1.19.0.postgres.sql.gz | Bin 0 -> 645 bytes .../migration-test/forgejo-v1.19.0.sqlite3.sql.gz | Bin 0 -> 200 bytes .../integration/migration-test/migration_test.go | 7 +++++-- 4 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 tests/integration/migration-test/forgejo-v1.19.0.mysql.sql.gz create mode 100644 tests/integration/migration-test/forgejo-v1.19.0.postgres.sql.gz create mode 100644 tests/integration/migration-test/forgejo-v1.19.0.sqlite3.sql.gz diff --git a/tests/integration/migration-test/forgejo-v1.19.0.mysql.sql.gz b/tests/integration/migration-test/forgejo-v1.19.0.mysql.sql.gz new file mode 100644 index 0000000000000000000000000000000000000000..4cea13baf8f05a13093024ee1fc153c9aa86e4d4 GIT binary patch literal 164 zcmV;V09*ebiwFQolG9`W18vT+3c@fHh2cF<amNHYRM+B=wpR(JH<Bhorv|Z>I3!TT z=a(XggZuX%PGeCz1Se~a5N>&yr+Xe>)AEQp1>g)I#A|>{oMU?OZ7G0^1M*sf^v;Zm z8jBs0D^~gqe|(F3>Gh{s(aEY#+5wI@0AI%i6M%G3ggcc|ZtIFE>d`t-<jkK}XQ@5* Sz&AxHD)t7Va4OHk0000B8c9|F literal 0 HcmV?d00001 diff --git a/tests/integration/migration-test/forgejo-v1.19.0.postgres.sql.gz b/tests/integration/migration-test/forgejo-v1.19.0.postgres.sql.gz new file mode 100644 index 0000000000000000000000000000000000000000..7fdc409dbbdea8a01e7907f7562047f9bcc40b05 GIT binary patch literal 645 zcmV;00($))iwFQ6j?-iS1C3O{Zlf>|z4H}wBaxzRb6Yjq10~KDEioyWZF@p47{ZnS zwN1PI`;H-Ln`|~M5<>R8nR##Ch=?#ynrpEUwN7-o5lyGz2b|BW2t!qqKKy%|R;59U zI&HGDE-+xnZ1LS5qFAoZxXhBYsq;o|5RoV?@uLvg)CT1fmqA-3Dc8JeiZdm24=;<6 ztpu0pI%&CH+Y_+y&3UE7c-wm|kW${&sV<v3xkm=V)a@~Q^ssTV5lZo*2Rw6GBZmPZ zo99G{w3DTNF{JW*W?AzvSOK|ZghpOK!CT<Li&zA0)fVcpnhl7^y&_BJL%7gFX@$f# zd}g^JaTwWw_Cl89GZG#NL2yGczyfF+r3)z(g56-bB$NR%Ig;T;U@sb3h(8TvBIjMD zVF=kKcObE+g$C?E58Qa{YFGT-jQ!s4HFjC1^~(R&7SXj2t!z?}b&^+5@w(`6*oJ_a z@s?Ji`F$l+%Tr+%<uLkO>UGkT*#{4I^qF(%laH#;@<DO(B&0(3VPpY5Wd`?UQP#TG zNMqlh^!Gc|5VXc`4t!qts3BWt$#qPqdon*MGhDC7o<+o*kPV}r_7@(-O8s~*@3vPo zfTc%&JAO>w&d%-o*>%t)n0{TrmcUUR+b#UMjK0d;uswl2E3*T70rgL2zyNjwKVDK} zqFIYMSvaxJpca4i6R$@0=k)B03n_}U;z}8dJsJ@lxJOa-$=xZl$!<l)(9b%8(R2dm z<9<bt{Gz@}Xadu7d?uh}Cl1%{v$6DsJM%dXhDI!OPzW6MX&=N3tU_<;gm>_Z+!-;Z f&(F|7wB!5#`D@@vR`I3pxijk(f6HdP`2_#~B&j{b literal 0 HcmV?d00001 diff --git a/tests/integration/migration-test/forgejo-v1.19.0.sqlite3.sql.gz b/tests/integration/migration-test/forgejo-v1.19.0.sqlite3.sql.gz new file mode 100644 index 0000000000000000000000000000000000000000..dba4bafbdc55b6f87640b5b3d2440e9b24f352ec GIT binary patch literal 200 zcmV;(05|_1iwFoEaMNS}17>e>XJu+{Ep{<3F*z<UE^~2gX>?^XE^~2g0A0<!3WGop z1mOOjVoL)SNqwYPWtAiMBj*~h@`_x<1QZkkdHbA2Qlyw>n2%{Z)&}9etZ^FW;ThlC z*;SPk1=Y#|d$cW<telmi^n^^nSZIQf$QU2X@QUj;Epvb@Ot%2aGS%dv@yej@;X*xN z$4=SA4Os^3QaY`32tWH(dw-BZ*_J%-t%JWGxT5Z;%})6-4NGT?Vktgj&(gie0000< CAX{<( literal 0 HcmV?d00001 diff --git a/tests/integration/migration-test/migration_test.go b/tests/integration/migration-test/migration_test.go index 556a54015b..82253739ea 100644 --- a/tests/integration/migration-test/migration_test.go +++ b/tests/integration/migration-test/migration_test.go @@ -98,7 +98,7 @@ func availableVersions() ([]string, error) { return nil, err } defer migrationsDir.Close() - versionRE, err := regexp.Compile("gitea-v(?P<version>.+)\\." + regexp.QuoteMeta(setting.Database.Type.String()) + "\\.sql.gz") + versionRE, err := regexp.Compile(".*-v(?P<version>.+)\\." + regexp.QuoteMeta(setting.Database.Type.String()) + "\\.sql.gz") if err != nil { return nil, err } @@ -122,7 +122,10 @@ func readSQLFromFile(version string) (string, error) { filename := fmt.Sprintf("tests/integration/migration-test/gitea-v%s.%s.sql.gz", version, setting.Database.Type) if _, err := os.Stat(filename); os.IsNotExist(err) { - return "", nil + filename = fmt.Sprintf("tests/integration/migration-test/forgejo-v%s.%s.sql.gz", version, setting.Database.Type) + if _, err := os.Stat(filename); os.IsNotExist(err) { + return "", nil + } } file, err := os.Open(filename)