-
Notifications
You must be signed in to change notification settings - Fork 2
/
blogit_test.go
45 lines (36 loc) · 1.14 KB
/
blogit_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// SPDX-FileCopyrightText: 2020-2024 caixw
//
// SPDX-License-Identifier: MIT
package blogit
import (
"testing"
"github.com/issue9/assert/v4"
"github.com/issue9/version"
"github.com/caixw/blogit/v2/internal/filesystem"
"github.com/caixw/blogit/v2/internal/testdata"
"github.com/caixw/blogit/v2/internal/vars"
)
func TestVersion(t *testing.T) {
a := assert.New(t, false)
a.True(version.SemVerValid(Version(true)))
a.True(version.SemVerValid(Version(false)))
}
func TestBuild(t *testing.T) {
a := assert.New(t, false)
// Dir
destDir, err := testdata.Temp()
a.NotError(err)
dest := DirFS(destDir)
a.NotError(Build(testdata.Source, dest, nil))
a.True(filesystem.Exists(dest, "index"+vars.Ext)).
True(filesystem.Exists(dest, "tags"+vars.Ext)).
True(filesystem.Exists(dest, "tags/default"+vars.Ext)).
True(filesystem.Exists(dest, "posts/p1"+vars.Ext))
// Memory
dest = MemoryFS()
a.NotError(Build(testdata.Source, dest, nil))
a.True(filesystem.Exists(dest, "index"+vars.Ext)).
True(filesystem.Exists(dest, "tags"+vars.Ext)).
True(filesystem.Exists(dest, "tags/default"+vars.Ext)).
True(filesystem.Exists(dest, "posts/p1"+vars.Ext))
}