From ac9b239e7398ee165dd458f2c7c3ead9a733577b Mon Sep 17 00:00:00 2001 From: Earl Warren 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) (cherry picked from commit 60463e3bab9dfa6aae7f379fc77309ab52b1d250) (cherry picked from commit b2fc2a7c1338ad2a9bd0a6887443e604dccda53f) (cherry picked from commit fb2759b6afc213d5e2db8f6e523391927c611b23) (cherry picked from commit 37cfc3b2275afd523f53e149781d69a2914fd83b) (cherry picked from commit 832607500a576a40ee1e35897e58ef319dba9788) --- .../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@fHh2cFI3!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-|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${&sVUGkT*#{4I^qF(%laH#;@w&d%-o*>%t)n0{TrmcUUR+b#UMjK0d;uswl2E3*T70rgL2zyNjwKVDK} zqFIYMSvaxJpca4i6R$@0=k)B03n_}U;z}8dJsJ@lxJOa-$=xZl$!_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?^XE^~2g0A0n2%{Z)&}9etZ^FW;ThlC z*;SPk1=Y#|d$cW.+)\\." + regexp.QuoteMeta(setting.Database.Type.String()) + "\\.sql.gz") + versionRE, err := regexp.Compile(".*-v(?P.+)\\." + 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)