Skip to content

Commit abd5c57

Browse files
simivartobiasehlert
authored andcommitted
Add tests for each of the sections
1 parent 35de5d3 commit abd5c57

File tree

5 files changed

+2463
-2
lines changed

5 files changed

+2463
-2
lines changed

Diff for: src/TibiaForumSection.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func TibiaForumSectionImpl(BoxContentHTML string) (*ForumSectionResponse, error)
8484
BoardsData = append(BoardsData, SectionBoard{
8585
ID: TibiaDataStringToInteger(subma1[0][1]),
8686
Name: subma1[0][2],
87-
Description: subma1[0][3],
87+
Description: TibiaDataSanitizeEscapedString(subma1[0][3]),
8888
Posts: TibiaDataStringToInteger(subma1[0][4]),
8989
Threads: TibiaDataStringToInteger(subma1[0][5]),
9090
LastPost: SectionBoardLastPost{

Diff for: src/TibiaForumSection_test.go

+122-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"testing"
88
)
99

10-
func TestForumsSectionWorldboard(t *testing.T) {
10+
func TestForumsSectionWorldBoard(t *testing.T) {
1111
file, err := static.TestFiles.Open("testdata/forums/section/worldboard.html")
1212
if err != nil {
1313
t.Fatalf("file opening error: %s", err)
@@ -48,3 +48,124 @@ func TestForumsSectionWorldboard(t *testing.T) {
4848
assert.Equal("Mad Mustazza", alumbra.LastPost.CharacterName)
4949
assert.Equal("2023-06-04T15:51:13Z", alumbra.LastPost.PostedAt)
5050
}
51+
52+
func TestForumsSectionSupportBoards(t *testing.T) {
53+
file, err := static.TestFiles.Open("testdata/forums/section/supportboards.html")
54+
if err != nil {
55+
t.Fatalf("file opening error: %s", err)
56+
}
57+
defer file.Close()
58+
59+
data, err := io.ReadAll(file)
60+
if err != nil {
61+
t.Fatalf("File reading error: %s", err)
62+
}
63+
64+
boardsJson, err := TibiaForumSectionImpl(string(data))
65+
if err != nil {
66+
t.Fatal(err)
67+
}
68+
69+
assert := assert.New(t)
70+
71+
assert.Equal(3, len(boardsJson.Boards))
72+
73+
paymentSupport := boardsJson.Boards[0]
74+
assert.Equal(20, paymentSupport.ID)
75+
assert.Equal("Payment Support", paymentSupport.Name)
76+
assert.Equal("Here you can ask questions on orders, payments and other payment issues.", paymentSupport.Description)
77+
assert.Equal(14468, paymentSupport.Threads)
78+
assert.Equal(56032, paymentSupport.Posts)
79+
assert.Equal(39400410, paymentSupport.LastPost.ID)
80+
assert.Equal("Dorieta", paymentSupport.LastPost.CharacterName)
81+
assert.Equal("2023-06-29T11:24:33Z", paymentSupport.LastPost.PostedAt)
82+
83+
technicalSupport := boardsJson.Boards[1]
84+
assert.Equal(13, technicalSupport.ID)
85+
assert.Equal("Technical Support", technicalSupport.Name)
86+
assert.Equal("Here you can ask for help if you have a technical problem that is related to Tibia.", technicalSupport.Description)
87+
assert.Equal(64722, technicalSupport.Threads)
88+
assert.Equal(301828, technicalSupport.Posts)
89+
assert.Equal(39400354, technicalSupport.LastPost.ID)
90+
assert.Equal("Dio Sorcer", technicalSupport.LastPost.CharacterName)
91+
assert.Equal("2023-06-29T01:47:59Z", technicalSupport.LastPost.PostedAt)
92+
93+
help := boardsJson.Boards[2]
94+
assert.Equal(113174, help.ID)
95+
assert.Equal("Help", help.Name)
96+
assert.Equal("Here you can ask other players all kind of questions about Tibia. Note that members of the CipSoft team will usually not reply here.", help.Description)
97+
assert.Equal(22788, help.Threads)
98+
assert.Equal(106713, help.Posts)
99+
assert.Equal(39400248, help.LastPost.ID)
100+
assert.Equal("Dekraken durinars", help.LastPost.CharacterName)
101+
assert.Equal("2023-06-28T17:17:45Z", help.LastPost.PostedAt)
102+
}
103+
104+
func TestForumsSectionCommunityBoards(t *testing.T) {
105+
file, err := static.TestFiles.Open("testdata/forums/section/communityboards.html")
106+
if err != nil {
107+
t.Fatalf("file opening error: %s", err)
108+
}
109+
defer file.Close()
110+
111+
data, err := io.ReadAll(file)
112+
if err != nil {
113+
t.Fatalf("File reading error: %s", err)
114+
}
115+
116+
boardsJson, err := TibiaForumSectionImpl(string(data))
117+
if err != nil {
118+
t.Fatal(err)
119+
}
120+
121+
assert := assert.New(t)
122+
123+
assert.Equal(6, len(boardsJson.Boards))
124+
125+
gameplay := boardsJson.Boards[0]
126+
assert.Equal(120835, gameplay.ID)
127+
assert.Equal("Gameplay (English Only)", gameplay.Name)
128+
assert.Equal("Here is the place to talk about quests, achievements and the general gameplay of Tibia.", gameplay.Description)
129+
assert.Equal(35364, gameplay.Threads)
130+
assert.Equal(335328, gameplay.Posts)
131+
assert.Equal(39400492, gameplay.LastPost.ID)
132+
assert.Equal("Dreamsphere", gameplay.LastPost.CharacterName)
133+
assert.Equal("2023-06-29T19:59:41Z", gameplay.LastPost.PostedAt)
134+
135+
auditorium := boardsJson.Boards[5]
136+
assert.Equal(89516, auditorium.ID)
137+
assert.Equal("Auditorium (English Only)", auditorium.Name)
138+
assert.Equal("Meet Tibia's community managers and give feedback on news articles and Tibia related topics. State your opinion and see what others think and have to say.", auditorium.Description)
139+
}
140+
141+
func TestForumsSectionTradeBoards(t *testing.T) {
142+
file, err := static.TestFiles.Open("testdata/forums/section/tradeboards.html")
143+
if err != nil {
144+
t.Fatalf("file opening error: %s", err)
145+
}
146+
defer file.Close()
147+
148+
data, err := io.ReadAll(file)
149+
if err != nil {
150+
t.Fatalf("File reading error: %s", err)
151+
}
152+
153+
boardsJson, err := TibiaForumSectionImpl(string(data))
154+
if err != nil {
155+
t.Fatal(err)
156+
}
157+
158+
assert := assert.New(t)
159+
160+
assert.Equal(90, len(boardsJson.Boards))
161+
162+
adra := boardsJson.Boards[0]
163+
assert.Equal(146485, adra.ID)
164+
assert.Equal("Adra - Trade", adra.Name)
165+
assert.Equal("Use this board to make Tibia related trade offers on the game world Adra. Note that all trades must conform to the Tibia Rules.", adra.Description)
166+
assert.Equal(540, adra.Threads)
167+
assert.Equal(599, adra.Posts)
168+
assert.Equal(39400121, adra.LastPost.ID)
169+
assert.Equal("Arge Reotona", adra.LastPost.CharacterName)
170+
assert.Equal("2023-06-28T09:15:31Z", adra.LastPost.PostedAt)
171+
}

0 commit comments

Comments
 (0)