Skip to content

Commit

Permalink
Regression test for fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonbullock committed Apr 3, 2022
1 parent 06e4c0d commit 3fdfd65
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 6 deletions.
24 changes: 18 additions & 6 deletions jbake-core/src/test/java/org/jbake/app/CrawlerTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.jbake.app;

import com.orientechnologies.orient.core.db.record.OTrackedMap;
import org.apache.commons.io.FilenameUtils;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
Expand All @@ -12,6 +13,8 @@
import org.junit.BeforeClass;
import org.junit.Test;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

import static org.assertj.core.api.Assertions.assertThat;
Expand Down Expand Up @@ -59,12 +62,21 @@ public void crawlDataFiles() {
DocumentTypes.addDocumentType(config.getDataFileDocType());
db.updateSchema();
crawler.crawlDataFiles();
Assert.assertEquals(1, db.getDocumentCount("data"));

DataFileUtil util = new DataFileUtil(db, "data");
Map<String, Object> data = util.get("videos.yaml");
Assert.assertFalse(data.isEmpty());
Assert.assertNotNull(data.get("data"));
Assert.assertEquals(2, db.getDocumentCount("data"));

DataFileUtil dataFileUtil = new DataFileUtil(db, "data");
Map<String, Object> videos = dataFileUtil.get("videos.yaml");
Assert.assertFalse(videos.isEmpty());
Assert.assertNotNull(videos.get("data"));

// regression test for issue 747
Map<String, Object> authorsFileContents = dataFileUtil.get("authors.yaml");
Assert.assertFalse(authorsFileContents.isEmpty());
Object authorsList = authorsFileContents.get("authors");
assertThat(authorsList).isNotInstanceOf(OTrackedMap.class);
assertThat(authorsList).isInstanceOf(LinkedHashMap.class);
LinkedHashMap<String, Map<String, Object>> authors = (LinkedHashMap<String, Map<String, Object>>) authorsList;
assertThat(authors.get("Joe Bloggs").get("last_name")).isEqualTo("Bloggs");
}

@Test
Expand Down
23 changes: 23 additions & 0 deletions jbake-core/src/test/resources/fixture/data/authors.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
authors:

John Smith:
first_name: John
last_name: Smith
twitter: "@jsmith"
facebook: "https://www.facebook.com/jsmith"

Jane Smith:
first_name: Jane
last_name: Smith
twitter: "@janesmith"

Joe Bloggs:
first_name: Joe
last_name: Bloggs
twitter: "@jblogs"

Tom Harry:
first_name: Tom
last_name: Harry
twitter: "@tharry"
facebook: "https://www.facebook.com/tharry"

0 comments on commit 3fdfd65

Please sign in to comment.