Skip to content

Commit c51ca9c

Browse files
authored
new world record_date field omit if empty (#350)
1 parent b379b68 commit c51ca9c

File tree

3 files changed

+818
-1
lines changed

3 files changed

+818
-1
lines changed

src/TibiaWorldsWorld.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type World struct {
2222
Status string `json:"status"` // The current status of the world.
2323
PlayersOnline int `json:"players_online"` // The number of currently online players.
2424
RecordPlayers int `json:"record_players"` // The world's online players record.
25-
RecordDate string `json:"record_date"` // The date when the record was achieved.
25+
RecordDate string `json:"record_date,omitempty"` // The date when the record was achieved.
2626
CreationDate string `json:"creation_date"` // The year and month it was created.
2727
Location string `json:"location"` // The physical location of the servers.
2828
PvpType string `json:"pvp_type"` // The type of PvP.

src/TibiaWorldsWorld_test.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,41 @@ func TestWorldZuna(t *testing.T) {
178178
assert.Equal(20, firstPlayer.Level)
179179
assert.Equal("Paladin", firstPlayer.Vocation)
180180
}
181+
182+
func TestWorldOceanis(t *testing.T) {
183+
file, err := static.TestFiles.Open("testdata/worlds/world/Oceanis.html")
184+
if err != nil {
185+
t.Fatalf("file opening error: %s", err)
186+
}
187+
defer file.Close()
188+
189+
data, err := io.ReadAll(file)
190+
if err != nil {
191+
t.Fatalf("File reading error: %s", err)
192+
}
193+
194+
worldJson, err := TibiaWorldsWorldImpl("Oceanis", string(data))
195+
if err != nil {
196+
t.Fatal(err)
197+
}
198+
199+
assert := assert.New(t)
200+
world := worldJson.World
201+
202+
assert.Equal("Oceanis", world.Name)
203+
assert.Equal("offline", world.Status)
204+
assert.Equal(0, world.PlayersOnline)
205+
assert.Equal(0, world.RecordPlayers)
206+
assert.Empty(world.RecordDate)
207+
assert.Equal("2024-04", world.CreationDate)
208+
assert.Equal("Oceania", world.Location)
209+
assert.Equal("Optional PvP", world.PvpType)
210+
assert.False(world.PremiumOnly)
211+
assert.Equal("regular", world.TransferType)
212+
assert.Equal(0, len(world.WorldsQuestTitles))
213+
assert.True(world.BattleyeProtected)
214+
assert.Equal("2024-04-10", world.BattleyeDate)
215+
assert.Equal("regular", world.GameWorldType)
216+
assert.Empty(world.TournamentWorldType)
217+
assert.Equal(0, len(world.OnlinePlayers))
218+
}

0 commit comments

Comments
 (0)