some tests and major cleanup
This commit is contained in:
parent
8ef2a2547c
commit
16671b3406
30 changed files with 192057 additions and 202431 deletions
50
pkg/cache/cache_test.go
vendored
Normal file
50
pkg/cache/cache_test.go
vendored
Normal 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()
|
||||
}
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue