some tests and major cleanup

This commit is contained in:
ston1th 2018-10-19 23:08:32 +02:00
commit 16671b3406
30 changed files with 192057 additions and 202431 deletions

50
pkg/cache/cache_test.go vendored Normal file
View file

@ -0,0 +1,50 @@
// Copyright (C) 2018 Marius Schellenberger
package cache
import (
"git.giftfish.de/ston1th/gowiki/pkg/core"
"testing"
)
func TestCache(t *testing.T) {
title := "test/page"
pages := []*core.Page{
&core.Page{
Title: title,
Markdown: "page v1",
},
&core.Page{
Title: title,
Markdown: "page v2",
},
}
c := NewCache()
t.Run("Add", func(t *testing.T) {
c.Add(title, pages[0])
})
t.Run("Get", func(t *testing.T) {
p := c.Get(title)
if p.Markdown != pages[0].Markdown {
t.Fail()
}
})
t.Run("Add", func(t *testing.T) {
c.Add(title, pages[1])
})
t.Run("Get", func(t *testing.T) {
p := c.Get(title)
if p.Markdown == pages[0].Markdown {
t.Fail()
}
})
t.Run("Delete", func(t *testing.T) {
c.Delete(title)
})
t.Run("Get", func(t *testing.T) {
p := c.Get(title)
if p != nil {
t.Fail()
}
})
}