Fix ParseLinks calls
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Peter Stuifzand 2020-07-01 00:55:33 +02:00
parent 1003c19662
commit beaa6202a6
3 changed files with 8 additions and 4 deletions

View File

@ -75,7 +75,7 @@ func processBackrefsForPage(page Page, refs Refs) error {
link: link:
for _, link := range links { for _, link := range links {
for i, ref := range refs[link.PageName] { for i, ref := range refs[link.PageName] {
if ref.Link.Id == link.Id { if ref.Link.ID == link.ID {
refs[link.PageName][i].Link = link refs[link.PageName][i].Link = link
continue link continue link
} }

View File

@ -10,7 +10,7 @@ import (
) )
type ParsedLink struct { type ParsedLink struct {
Id string ID string `json:"Id"`
Name string Name string
PageName string PageName string
Line string Line string

View File

@ -9,7 +9,7 @@ import (
func TestParseLinks(t *testing.T) { func TestParseLinks(t *testing.T) {
example := "There are three types of notes and these should be kept seperate, because they have different goals. [[Fleeting notes]], [[Permanent notes]], [[Project notes]]." example := "There are three types of notes and these should be kept seperate, because they have different goals. [[Fleeting notes]], [[Permanent notes]], [[Project notes]]."
links, err := ParseLinks(example) links, err := ParseLinks("id", example)
if assert.NoError(t, err, "should parse example") { if assert.NoError(t, err, "should parse example") {
assert.Len(t, links, 3, "should contain 3 links") assert.Len(t, links, 3, "should contain 3 links")
@ -17,14 +17,17 @@ func TestParseLinks(t *testing.T) {
assert.Equal(t, links[0].Line, "There are three types of notes and these should be kept seperate, because they have different goals. [[Fleeting notes]], [[Permanent notes]], [[Project notes]].") assert.Equal(t, links[0].Line, "There are three types of notes and these should be kept seperate, because they have different goals. [[Fleeting notes]], [[Permanent notes]], [[Project notes]].")
assert.Equal(t, links[0].Name, "Fleeting notes") assert.Equal(t, links[0].Name, "Fleeting notes")
assert.Equal(t, links[0].PageName, "Fleeting_notes") assert.Equal(t, links[0].PageName, "Fleeting_notes")
assert.Equal(t, links[0].ID, "id")
assert.Equal(t, links[1].Line, "There are three types of notes and these should be kept seperate, because they have different goals. [[Fleeting notes]], [[Permanent notes]], [[Project notes]].") assert.Equal(t, links[1].Line, "There are three types of notes and these should be kept seperate, because they have different goals. [[Fleeting notes]], [[Permanent notes]], [[Project notes]].")
assert.Equal(t, links[1].Name, "Permanent notes") assert.Equal(t, links[1].Name, "Permanent notes")
assert.Equal(t, links[1].PageName, "Permanent_notes") assert.Equal(t, links[1].PageName, "Permanent_notes")
assert.Equal(t, links[1].ID, "id")
assert.Equal(t, links[2].Line, "There are three types of notes and these should be kept seperate, because they have different goals. [[Fleeting notes]], [[Permanent notes]], [[Project notes]].") assert.Equal(t, links[2].Line, "There are three types of notes and these should be kept seperate, because they have different goals. [[Fleeting notes]], [[Permanent notes]], [[Project notes]].")
assert.Equal(t, links[2].Name, "Project notes") assert.Equal(t, links[2].Name, "Project notes")
assert.Equal(t, links[2].PageName, "Project_notes") assert.Equal(t, links[2].PageName, "Project_notes")
assert.Equal(t, links[2].ID, "id")
} }
} }
@ -36,7 +39,7 @@ func TestTagLinks(t *testing.T) {
* #[[TODO]] Test4 * #[[TODO]] Test4
` `
links, err := ParseLinks(example) links, err := ParseLinks("id", example)
if assert.NoError(t, err, "should parse example") { if assert.NoError(t, err, "should parse example") {
assert.Len(t, links, 4, "should contain 3 links") assert.Len(t, links, 4, "should contain 3 links")
@ -44,5 +47,6 @@ func TestTagLinks(t *testing.T) {
assert.Equal(t, links[0].Line, "* #[[TODO]] Test1") assert.Equal(t, links[0].Line, "* #[[TODO]] Test1")
assert.Equal(t, links[0].Name, "TODO") assert.Equal(t, links[0].Name, "TODO")
assert.Equal(t, links[0].PageName, "TODO") assert.Equal(t, links[0].PageName, "TODO")
assert.Equal(t, links[0].ID, "TODO")
} }
} }