package verdict import "testing" // The outputs below are what the pinned images printed on 2026-09-27 // (liquibase 4.31.1-alpine, flyway 10.22.0-alpine, atlas 1.3.3-community-alpine), // trimmed to the lines that matter. const liquibaseTwoChangelogs = `Liquibase Open Source 4.31.1 by Liquibase UPDATE SUMMARY Run: 2 Previously run: 0 Filtered out: 0 ------------------------------- Total change sets: 2 Liquibase: Update has been successful. Rows affected: 4 Liquibase Open Source 4.31.1 by Liquibase UPDATE SUMMARY Run: 1 Previously run: 0 Filtered out: 0 ------------------------------- Total change sets: 1 ` // A changelog two of whose three changesets had already run. const liquibasePartlyRun = `UPDATE SUMMARY Run: 1 Previously run: 2 Filtered out: 0 ------------------------------- Total change sets: 3 ` const flywayTwo = `Successfully validated 2 migrations (execution time 00:00.020s) Migrating schema "main" to version "1 - a" Migrating schema "main" to version "2 - b" Successfully applied 2 migrations to schema "main", now at version v2 (execution time 00:00.006s) ` const flywayNothing = `Successfully validated 2 migrations (execution time 00:00.041s) Current version of schema "main": 2 Schema "main" is up to date. No migration necessary. ` const atlasTwo = `Migrating to version 20260927000002 (2 migrations in total): -- migrating version 20260927000001 -> CREATE TABLE t (id int); -- ok (1.2ms) -- migrating version 20260927000002 -> DROP TABLE t; -- ok (3.4ms) ------------------------- -- 11.18681ms -- 2 migrations -- 2 sql statements ` func TestAppliedCount(t *testing.T) { cases := []struct { tool, out string want int }{ {"liquibase", liquibaseTwoChangelogs, 3}, // "Previously run" and "Total change sets" are not what ran. {"liquibase", liquibasePartlyRun, 1}, {"liquibase", "UPDATE SUMMARY\nRun: 0\nPreviously run: 5\n", 0}, {"flyway", flywayTwo, 2}, {"flyway", flywayNothing, 0}, {"flyway", "Successfully applied 1 migration to schema \"main\"", 1}, {"atlas", atlasTwo, 2}, // One tool's markers count nothing for another. {"liquibase", flywayTwo, 0}, {"flyway", atlasTwo, 0}, {"atlas", liquibaseTwoChangelogs, 0}, {"none", liquibaseTwoChangelogs, 0}, } for _, c := range cases { if got := AppliedCount(c.tool, c.out); got != c.want { t.Errorf("AppliedCount(%q) = %d, want %d", c.tool, got, c.want) } } }