1
1
require "helper"
2
+ require "tmpdir"
2
3
3
4
Importers ::WordpressDotCom . require_deps
4
5
@@ -13,9 +14,11 @@ class TestWordpressDotComMigrator < Test::Unit::TestCase
13
14
assert File . exist? ( xml_path ) , "Expect xml file to exist"
14
15
tmpdir = Dir . mktmpdir
15
16
Dir . chdir ( tmpdir ) do
17
+ Jekyll . logger = ::Logger . new ( File . open ( "output.log" , "w" ) )
16
18
JekyllImport ::Importers ::WordpressDotCom . process ( { "source" => xml_path } )
19
+ Jekyll . logger = Jekyll ::Stevenson . new
17
20
end
18
-
21
+
19
22
# The old export produced the following files:
20
23
# .
21
24
# ├── _attachments
@@ -45,16 +48,21 @@ class TestWordpressDotComMigrator < Test::Unit::TestCase
45
48
# └── a-bright-night-sky-full-of-stars-and-the-milky.png
46
49
assert_path_exist File . expand_path ( "assets/2025/01/a-bright-night-sky-full-of-stars-and-the-milky.png" , tmpdir )
47
50
51
+ jekyllbot_author_data = {
52
+ "login" => "jekyllbot" ,
53
+
54
+ "display_name" => "jekyllbot" ,
55
+ "first_name" => "Jekyllbot" ,
56
+ "last_name" => "Hyde" ,
57
+ }
58
+
48
59
assert_path_exist File . expand_path ( "_pages/2025-01-19-about.html" , tmpdir )
49
60
page_content = File . read ( File . expand_path ( "_pages/2025-01-19-about.html" , tmpdir ) )
50
- assert_match %r{published: true} , page_content
51
- assert_match %r{permalink: "\/ about\/ "} , page_content
52
- assert_match %r{^author:\s *\n } , page_content
53
- assert_match %r{\s \s login: jekyllbot} , page_content
54
- assert_match %r{\s \s email: [email protected] } , page_content
55
- assert_match %r{\s \s display_name: jekyllbot} , page_content
56
- assert_match %r{\s \s first_name: Jekyllbot} , page_content
57
- assert_match %r{\s \s last_name: Hyde} , page_content
61
+ page_front_matter = page_content . match ( /^(---\n .*?---\n )/m ) [ 0 ]
62
+ page_data = YAML . safe_load ( page_front_matter )
63
+ assert_equal true , page_data [ "published" ]
64
+ assert_equal "/about/" , page_data [ "permalink" ]
65
+ assert_equal jekyllbot_author_data , page_data [ "author" ]
58
66
59
67
assert_path_exist File . expand_path ( "_posts/2025-01-18-blog-post-1.html" , tmpdir )
60
68
post_content = File . read ( File . expand_path ( "_posts/2025-01-18-blog-post-1.html" , tmpdir ) )
@@ -64,7 +72,7 @@ class TestWordpressDotComMigrator < Test::Unit::TestCase
64
72
assert_equal "Blog Post 1" , post_data [ "title" ]
65
73
assert_equal [ "Foo" ] , post_data [ "categories" ]
66
74
assert_equal [ "code" , "ruby" , "ship" , "stars" ] , post_data [ "tags" ]
67
- assert_equal "jekyllbot" , post_data [ "author" ] [ "login "]
75
+ assert_equal jekyllbot_author_data , post_data [ "author" ]
68
76
assert_equal "/2025/01/18/blog-post-1/" , post_data [ "permalink" ]
69
77
assert_equal "101042542514" , post_data [ "meta" ] [ "_publicize_job_id" ]
70
78
assert_includes post_content , "<p>This is a blog post.</p>"
0 commit comments