Skip to content

Commit 3160c00

Browse files
committed
Worlds & WorldsOverview func/test/webserver updates (pass url as args)
1 parent 3c83ca8 commit 3160c00

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

src/TibiaWorldsOverview.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ var (
4646
)
4747

4848
// TibiaWorldsOverview func
49-
func TibiaWorldsOverviewImpl(BoxContentHTML string) (WorldsOverviewResponse, error) {
49+
func TibiaWorldsOverviewImpl(BoxContentHTML string, url string) (WorldsOverviewResponse, error) {
5050
// Loading HTML data into ReaderHTML for goquery with NewReader
5151
ReaderHTML, err := goquery.NewDocumentFromReader(strings.NewReader(BoxContentHTML))
5252
if err != nil {
@@ -206,7 +206,7 @@ func TibiaWorldsOverviewImpl(BoxContentHTML string) (WorldsOverviewResponse, err
206206
Information{
207207
APIDetails: TibiaDataAPIDetails,
208208
Timestamp: TibiaDataDatetime(""),
209-
TibiaURL: "https://www.tibia.com/community/?subtopic=worlds",
209+
TibiaURL: []string{url},
210210
Status: Status{
211211
HTTPCode: http.StatusOK,
212212
},

src/TibiaWorldsOverview_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ func TestWorlds(t *testing.T) {
2020
t.Fatalf("File reading error: %s", err)
2121
}
2222

23-
worldsJson, err := TibiaWorldsOverviewImpl(string(data))
23+
worldsJson, err := TibiaWorldsOverviewImpl(string(data), "https://www.tibia.com/community/?subtopic=worlds")
2424
if err != nil {
2525
t.Fatal(err)
2626
}
2727

2828
assert := assert.New(t)
2929
information := worldsJson.Information
3030

31-
assert.Equal("https://www.tibia.com/community/?subtopic=worlds", information.TibiaURL)
31+
assert.Equal("https://www.tibia.com/community/?subtopic=worlds", information.TibiaURL[0])
3232

3333
assert.Equal(8720, worldsJson.Worlds.PlayersOnline)
3434
assert.Equal(64028, worldsJson.Worlds.RecordPlayers)

src/TibiaWorldsWorld.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ var (
5050
)
5151

5252
// TibiaWorldsWorld func
53-
func TibiaWorldsWorldImpl(world string, BoxContentHTML string) (WorldResponse, error) {
53+
func TibiaWorldsWorldImpl(world string, BoxContentHTML string, url string) (WorldResponse, error) {
5454
// TODO: We need to read the world name from the response rather than pass it into this func
5555

5656
// Loading HTML data into ReaderHTML for goquery with NewReader
@@ -230,7 +230,7 @@ func TibiaWorldsWorldImpl(world string, BoxContentHTML string) (WorldResponse, e
230230
Information: Information{
231231
APIDetails: TibiaDataAPIDetails,
232232
Timestamp: TibiaDataDatetime(""),
233-
TibiaURL: "https://www.tibia.com/community/?subtopic=worlds&world=" + world,
233+
TibiaURL: []string{url},
234234
Status: Status{
235235
HTTPCode: http.StatusOK,
236236
},

src/TibiaWorldsWorld_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func TestWorldEndebra(t *testing.T) {
2020
t.Fatalf("File reading error: %s", err)
2121
}
2222

23-
worldJson, err := TibiaWorldsWorldImpl("Endebra", string(data))
23+
worldJson, err := TibiaWorldsWorldImpl("Endebra", string(data), "https://www.tibia.com/community/?subtopic=worlds&world=Endebra")
2424
if err != nil {
2525
t.Fatal(err)
2626
}
@@ -29,7 +29,7 @@ func TestWorldEndebra(t *testing.T) {
2929
world := worldJson.World
3030
information := worldJson.Information
3131

32-
assert.Equal("https://www.tibia.com/community/?subtopic=worlds&world=Endebra", information.TibiaURL)
32+
assert.Equal("https://www.tibia.com/community/?subtopic=worlds&world=Endebra", information.TibiaURL[0])
3333

3434
assert.Equal("Endebra", world.Name)
3535
assert.Equal("online", world.Status)
@@ -61,7 +61,7 @@ func TestWorldPremia(t *testing.T) {
6161
t.Fatalf("File reading error: %s", err)
6262
}
6363

64-
worldJson, err := TibiaWorldsWorldImpl("Premia", string(data))
64+
worldJson, err := TibiaWorldsWorldImpl("Premia", string(data), "")
6565
if err != nil {
6666
t.Fatal(err)
6767
}
@@ -103,7 +103,7 @@ func TestWorldWintera(t *testing.T) {
103103
t.Fatalf("File reading error: %s", err)
104104
}
105105

106-
worldJson, err := TibiaWorldsWorldImpl("Wintera", string(data))
106+
worldJson, err := TibiaWorldsWorldImpl("Wintera", string(data), "")
107107
if err != nil {
108108
t.Fatal(err)
109109
}
@@ -150,7 +150,7 @@ func TestWorldZuna(t *testing.T) {
150150
t.Fatalf("File reading error: %s", err)
151151
}
152152

153-
worldJson, err := TibiaWorldsWorldImpl("Zuna", string(data))
153+
worldJson, err := TibiaWorldsWorldImpl("Zuna", string(data), "")
154154
if err != nil {
155155
t.Fatal(err)
156156
}
@@ -195,7 +195,7 @@ func TestWorldOceanis(t *testing.T) {
195195
t.Fatalf("File reading error: %s", err)
196196
}
197197

198-
worldJson, err := TibiaWorldsWorldImpl("Oceanis", string(data))
198+
worldJson, err := TibiaWorldsWorldImpl("Oceanis", string(data), "")
199199
if err != nil {
200200
t.Fatal(err)
201201
}

src/webserver.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,7 @@ func tibiaWorldsOverview(c *gin.Context) {
10331033
c,
10341034
tibiadataRequest,
10351035
func(BoxContentHTML string) (interface{}, error) {
1036-
return TibiaWorldsOverviewImpl(BoxContentHTML)
1036+
return TibiaWorldsOverviewImpl(BoxContentHTML, tibiadataRequest.URL)
10371037
},
10381038
"TibiaWorldsOverview")
10391039
}
@@ -1078,7 +1078,7 @@ func tibiaWorldsWorld(c *gin.Context) {
10781078
c,
10791079
tibiadataRequest,
10801080
func(BoxContentHTML string) (interface{}, error) {
1081-
return TibiaWorldsWorldImpl(world, BoxContentHTML)
1081+
return TibiaWorldsWorldImpl(world, BoxContentHTML, tibiadataRequest.URL)
10821082
},
10831083
"TibiaWorldsWorld")
10841084
}

0 commit comments

Comments
 (0)