@@ -6,6 +6,55 @@ import (
6
6
"github.com/stretchr/testify/assert"
7
7
)
8
8
9
+ /* -------------------- Tag -------------------- */
10
+
11
+ func Test_Tag_NewTag (t * testing.T ) {
12
+ actual := NewTag ("ada" , & Page {Title : "test" })
13
+
14
+ assert .IsType (t , & Tag {}, actual )
15
+ assert .Equal (t , "ada" , actual .Name )
16
+ assert .Equal (t , "test" , actual .Pages [0 ].Title )
17
+ }
18
+
19
+ func Test_Tag_AddPage (t * testing.T ) {
20
+ tag := NewTag ("ada" , & Page {Title : "test" })
21
+ tag .AddPage (& Page {Title : "zombies" })
22
+
23
+ assert .Equal (t , 2 , len (tag .Pages ))
24
+ assert .Equal (t , "zombies" , tag .Pages [1 ].Title )
25
+ }
26
+
27
+ func Test_Tag_IsValid (t * testing.T ) {
28
+ tests := []struct {
29
+ name string
30
+ title string
31
+ expected bool
32
+ }{
33
+ {
34
+ name : "when invalid" ,
35
+ title : "" ,
36
+ expected : false ,
37
+ },
38
+ {
39
+ name : "when valid" ,
40
+ title : "test" ,
41
+ expected : true ,
42
+ },
43
+ }
44
+
45
+ for _ , tt := range tests {
46
+ t .Run (tt .name , func (t * testing.T ) {
47
+ tag := NewTag (tt .title , & Page {})
48
+
49
+ actual := tag .IsValid ()
50
+
51
+ assert .Equal (t , tt .expected , actual )
52
+ })
53
+ }
54
+ }
55
+
56
+ /* -------------------- TagMap -------------------- */
57
+
9
58
func Test_NewTagMap (t * testing.T ) {
10
59
tests := []struct {
11
60
name string
0 commit comments