From 2dfe103687f2c3c63ba03cd6ef2b86c03d582c28 Mon Sep 17 00:00:00 2001 From: benjamin wil Date: Sat, 30 Apr 2022 23:03:56 -0700 Subject: [PATCH] Ensure example git repos are valid (#1821) * Ensure example git repos are valid It was reported in #1817 that the `lotr_migration.git` repository we use in `test/test_migrate.rb` is not a valid git repository on when clone, causing the test suite to fail when run locally. The reason is because there is no `.git/refs` directory, meaning it's not really a valid git repository at all. I noticed that the `empty.git` example repository has the same problem. This commit simply ensures that the directory structure of these example repositories are persisted in git. * Run `test_migrate` tests on CI Now that we've resolved the issue with the invalid git repository in the parent commit, we can run all of the tests in our CI environment. --- test/examples/empty.git/refs/heads/.keep | 0 .../lotr_migration.git/refs/heads/.keep | 0 test/test_migrate.rb | 96 +++++++++---------- 3 files changed, 47 insertions(+), 49 deletions(-) create mode 100644 test/examples/empty.git/refs/heads/.keep create mode 100644 test/examples/lotr_migration.git/refs/heads/.keep diff --git a/test/examples/empty.git/refs/heads/.keep b/test/examples/empty.git/refs/heads/.keep new file mode 100644 index 00000000..e69de29b diff --git a/test/examples/lotr_migration.git/refs/heads/.keep b/test/examples/lotr_migration.git/refs/heads/.keep new file mode 100644 index 00000000..e69de29b diff --git a/test/test_migrate.rb b/test/test_migrate.rb index ec4d711f..89c48239 100644 --- a/test/test_migrate.rb +++ b/test/test_migrate.rb @@ -25,62 +25,60 @@ def load_script(**args) end end -unless ENV['CI'] - context '4.x -> 5.x tag migrator' do - include Rack::Test::Methods +context '4.x -> 5.x tag migrator' do + include Rack::Test::Methods - setup do - @path = cloned_testpath("examples/lotr_migration.git") - end + setup do + @path = cloned_testpath("examples/lotr_migration.git") + end - test 'repair broken links' do - # The original contents of Subdir/Foo.md: - # - # waa - # [[Samwi]] - # [[samwise gamgee.mediaWiki]] - # [[Samwise Gamgee.mediawiki]] - # [[Samwise Gamgee]] - # [[Test|Samwise Gamgee#Anchor]] - # [[Waaa|Test]] - # [[Zaa]] - # - # The contents will be updated after running the migration script. - load_script + test 'repair broken links' do + # The original contents of Subdir/Foo.md: + # + # waa + # [[Samwi]] + # [[samwise gamgee.mediaWiki]] + # [[Samwise Gamgee.mediawiki]] + # [[Samwise Gamgee]] + # [[Test|Samwise Gamgee#Anchor]] + # [[Waaa|Test]] + # [[Zaa]] + # + # The contents will be updated after running the migration script. + load_script - file = ::File.new(::File.join(@path, 'Subdir/Foo.md'), 'r') - assert_equal <<~FILE_CONTENTS, file.read - waa - [[Samwi]] - [[/Samwise Gamgee.mediawiki]] - [[/Samwise Gamgee.mediawiki]] - [[/Samwise Gamgee.md]] - [[Test|/Samwise Gamgee.md#Anchor]] - [[Waaa|/Bar/Test.md]] - [[Subsub/Zaa.md]] - FILE_CONTENTS - end + file = ::File.new(::File.join(@path, 'Subdir/Foo.md'), 'r') + assert_equal <<~FILE_CONTENTS, file.read + waa + [[Samwi]] + [[/Samwise Gamgee.mediawiki]] + [[/Samwise Gamgee.mediawiki]] + [[/Samwise Gamgee.md]] + [[Test|/Samwise Gamgee.md#Anchor]] + [[Waaa|/Bar/Test.md]] + [[Subsub/Zaa.md]] + FILE_CONTENTS + end - test 'change spaced filenames to hyphenated filenames' do - load_script(hyphenate: true) + test 'change spaced filenames to hyphenated filenames' do + load_script(hyphenate: true) - f = ::File.new(::File.join(@path, 'Home.textile'), 'r') - output = f.read - assert_equal true, output.include?('[[Bilbo-Baggins.md]]') - assert_equal true, output.include?('[[evil|Mordor/Eye-Of-Sauron.md]]') - end + f = ::File.new(::File.join(@path, 'Home.textile'), 'r') + output = f.read + assert_equal true, output.include?('[[Bilbo-Baggins.md]]') + assert_equal true, output.include?('[[evil|Mordor/Eye-Of-Sauron.md]]') + end - test 'migration with page file dir' do - load_script(page_file_dir: 'Subdir') + test 'migration with page file dir' do + load_script(page_file_dir: 'Subdir') - f = ::File.new(::File.join(@path, 'Subdir/Foo.md'), 'r') - output = f.read - assert_equal true, output.include?('[[Subsub/Zaa.md]]') - assert_equal true, output.include?('[[Samwi]]') - end + f = ::File.new(::File.join(@path, 'Subdir/Foo.md'), 'r') + output = f.read + assert_equal true, output.include?('[[Subsub/Zaa.md]]') + assert_equal true, output.include?('[[Samwi]]') + end - teardown do - FileUtils.rm_rf(@path) - end + teardown do + FileUtils.rm_rf(@path) end end