Skip to content

Commit 1248dc0

Browse files
authored
Merge pull request #15 from joshraphael/issue-14
issue-14 -- Various general fixes
2 parents 46a824a + 0f6a1f3 commit 1248dc0

File tree

12 files changed

+49
-163
lines changed

12 files changed

+49
-163
lines changed

.github/workflows/go.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,16 @@ jobs:
4040
config: ./.github/.testcoverage.yml
4141
local-prefix: github.com/joshraphael/go-retroachievements
4242
git-token: ${{ github.ref_name == 'main' && secrets.GITHUB_TOKEN || '' }}
43-
git-branch: badges
43+
git-branch: badges
44+
45+
smoke:
46+
name: smoke
47+
runs-on: ubuntu-latest
48+
env:
49+
RA_API_KEY: ${{ secrets.RA_API_KEY }}
50+
steps:
51+
- uses: actions/checkout@v3
52+
- uses: actions/setup-go@v3
53+
54+
- name: smoke test endpoints
55+
run: bash ./scripts/smoke.sh

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@ outfile := coverage
55
test:
66
bash ./scripts/test.sh --open
77

8+
smoke:
9+
bash ./scripts/smoke.sh
10+
811
docs:
912
godoc -http=:8080

event_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import (
1414

1515
func TestGetAchievementOfTheWeek(tt *testing.T) {
1616
achievementType := "progression"
17-
dateCreated, err := time.Parse(time.DateTime, "2012-11-02 00:03:12")
17+
dateCreated, err := time.Parse(time.DateOnly, "2012-11-02")
1818
require.NoError(tt, err)
19-
dateModified, err := time.Parse(time.DateTime, "2023-09-30 02:00:49")
19+
dateModified, err := time.Parse(time.DateOnly, "2023-09-30")
2020
require.NoError(tt, err)
2121
dateAwarded, err := time.Parse(time.RFC3339Nano, "2024-11-22T17:25:17.000000Z")
2222
require.NoError(tt, err)
@@ -88,10 +88,10 @@ func TestGetAchievementOfTheWeek(tt *testing.T) {
8888
Points: 5,
8989
TrueRatio: 7,
9090
Author: "Scott",
91-
DateCreated: models.DateTime{
91+
DateCreated: &models.DateOnly{
9292
Time: dateCreated,
9393
},
94-
DateModified: models.DateTime{
94+
DateModified: &models.DateOnly{
9595
Time: dateModified,
9696
},
9797
Type: &achievementType,

examples/user/getuserwanttoplaylist/getuserwanttoplaylist.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func main() {
1818
client := retroachievements.NewClient(secret)
1919

2020
resp, err := client.GetUserWantToPlayList(models.GetUserWantToPlayListParameters{
21-
Username: "jamiras",
21+
Username: "spoony",
2222
})
2323
if err != nil {
2424
panic(err)

game_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ func TestGetGameExtended(tt *testing.T) {
222222
Time: released,
223223
},
224224
ID: 2991,
225-
IsFinal: 0,
225+
IsFinal: false,
226226
RichPresencePatch: "e7a5e12072a6c976a1146756726fdd8c",
227227
Updated: &updated,
228228
ConsoleName: "PlayStation 2",
@@ -311,7 +311,7 @@ func TestGetGameExtended(tt *testing.T) {
311311
Time: released,
312312
},
313313
ID: 2991,
314-
IsFinal: 0,
314+
IsFinal: false,
315315
RichPresencePatch: "e7a5e12072a6c976a1146756726fdd8c",
316316
Updated: &updated,
317317
ConsoleName: "PlayStation 2",
@@ -359,7 +359,7 @@ func TestGetGameExtended(tt *testing.T) {
359359
require.Equal(t, "Vehicular Combat", resp.Genre)
360360
require.Equal(t, released, resp.Released.Time)
361361
require.Equal(t, 2991, resp.ID)
362-
require.Equal(t, 0, resp.IsFinal)
362+
require.False(t, resp.IsFinal)
363363
require.Equal(t, "e7a5e12072a6c976a1146756726fdd8c", resp.RichPresencePatch)
364364
require.Equal(t, updated, *resp.Updated)
365365
require.Equal(t, "PlayStation 2", resp.ConsoleName)

models/event.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ type GetAchievementOfTheWeek struct {
1515
}
1616

1717
type GetAchievementOfTheWeekAchievement struct {
18-
ID int `json:"ID"`
19-
Title string `json:"Title"`
20-
Description string `json:"Description"`
21-
Points int `json:"Points"`
22-
TrueRatio int `json:"TrueRatio"`
23-
Author string `json:"Author"`
24-
DateCreated DateTime `json:"DateCreated"`
25-
DateModified DateTime `json:"DateModified"`
26-
Type *string `json:"Type"`
18+
ID int `json:"ID"`
19+
Title string `json:"Title"`
20+
Description string `json:"Description"`
21+
Points int `json:"Points"`
22+
TrueRatio int `json:"TrueRatio"`
23+
Author string `json:"Author"`
24+
DateCreated *DateOnly `json:"DateCreated"`
25+
DateModified *DateOnly `json:"DateModified"`
26+
Type *string `json:"Type"`
2727
}
2828

2929
type GetAchievementOfTheWeekConsole struct {

models/game.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ type GetGameExtented struct {
5050
Genre string `json:"Genre"`
5151
Released *DateOnly `json:"Released"`
5252
ID int `json:"ID"`
53-
IsFinal int `json:"IsFinal"`
53+
IsFinal bool `json:"IsFinal"`
5454
RichPresencePatch string `json:"RichPresencePatch"`
5555
GuideURL *string `json:"GuideURL"`
5656
Updated *time.Time `json:"Updated"`

models/time.go

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -60,37 +60,6 @@ func (do *DateOnly) String() string {
6060
return fmt.Sprintf("%q", do.Format(time.DateOnly))
6161
}
6262

63-
// LongMonthDate is a time data structure that can be used for string dates formatted as "January 02, 2006"
64-
type LongMonthDate struct {
65-
time.Time
66-
}
67-
68-
const (
69-
LongMonthDateFormat = "January 2, 2006"
70-
)
71-
72-
func (lmd *LongMonthDate) UnmarshalJSON(b []byte) (err error) {
73-
s := strings.Trim(string(b), `"`)
74-
if s == "" {
75-
*lmd = LongMonthDate{time.Time{}}
76-
return nil
77-
}
78-
nt, err := time.Parse(LongMonthDateFormat, s)
79-
if err != nil {
80-
return err
81-
}
82-
*lmd = LongMonthDate{nt}
83-
return nil
84-
}
85-
86-
func (lmd LongMonthDate) MarshalJSON() ([]byte, error) {
87-
return []byte(lmd.String()), nil
88-
}
89-
90-
func (lmd *LongMonthDate) String() string {
91-
return fmt.Sprintf("%q", lmd.Format(LongMonthDateFormat))
92-
}
93-
9463
// RFC3339NumColonTZ is a time data structure that can be used for string dates formatted as "2006-01-02T15:04:05-07:00"
9564
type RFC3339NumColonTZ struct {
9665
time.Time

models/time_test.go

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -61,59 +61,6 @@ func TestDateTimeString(tt *testing.T) {
6161
require.Equal(tt, `"`+expectedString+`"`, d.String())
6262
}
6363

64-
func TestLongMonthDateUnmarshalJSON(tt *testing.T) {
65-
tests := []struct {
66-
name string
67-
input string
68-
assert func(t *testing.T, date *models.LongMonthDate, err error)
69-
}{
70-
{
71-
name: "empty string default",
72-
input: "\"\"",
73-
assert: func(t *testing.T, date *models.LongMonthDate, err error) {
74-
require.NotNil(t, date)
75-
require.True(t, date.Time.IsZero())
76-
require.NoError(t, err)
77-
},
78-
},
79-
{
80-
name: "unknown bytes",
81-
input: "\"?>?>>L:\"",
82-
assert: func(t *testing.T, date *models.LongMonthDate, err error) {
83-
require.NotNil(t, date)
84-
require.True(t, date.Time.IsZero())
85-
require.EqualError(t, err, "parsing time \"?>?>>L:\" as \"January 2, 2006\": cannot parse \"?>?>>L:\" as \"January\"")
86-
},
87-
},
88-
{
89-
name: "successfully unmarshal",
90-
input: "\"March 02, 2024\"",
91-
assert: func(t *testing.T, date *models.LongMonthDate, err error) {
92-
ts, tErr := time.Parse(models.LongMonthDateFormat, "March 2, 2024")
93-
require.NoError(t, tErr)
94-
require.NotNil(t, date)
95-
require.Equal(t, ts, date.Time)
96-
require.NoError(t, err)
97-
},
98-
},
99-
}
100-
for _, test := range tests {
101-
tt.Run(test.name, func(t *testing.T) {
102-
d := &models.LongMonthDate{}
103-
err := d.UnmarshalJSON([]byte(test.input))
104-
test.assert(t, d, err)
105-
})
106-
}
107-
}
108-
109-
func TestLongMonthDateString(tt *testing.T) {
110-
expectedString := "March 2, 2024"
111-
t, err := time.Parse(models.LongMonthDateFormat, expectedString)
112-
require.NoError(tt, err)
113-
d := &models.LongMonthDate{t}
114-
require.Equal(tt, `"`+expectedString+`"`, d.String())
115-
}
116-
11764
func TestRFC3339NumColonTZUnmarshalJSON(tt *testing.T) {
11865
tests := []struct {
11966
name string

models/user.go

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ type GetGameInfoAndUserProgress struct {
286286
Genre string `json:"Genre"`
287287
Released *DateOnly `json:"Released"`
288288
ReleasedAtGranularity *string `json:"ReleasedAtGranularity"`
289-
IsFinal int `json:"IsFinal"`
289+
IsFinal bool `json:"IsFinal"`
290290
RichPresencePatch string `json:"RichPresencePatch"`
291291
GuideURL *string `json:"GuideURL"`
292292
ConsoleName string `json:"ConsoleName"`
@@ -499,7 +499,6 @@ type GetUserSummary struct {
499499
RecentlyPlayed []GetUserSummaryRecentlyPlayed `json:"RecentlyPlayed"`
500500
Awarded map[string]GetUserSummaryAwarded `json:"Awarded"`
501501
RecentAchievements map[string]map[string]GetUserSummaryRecentAchievements `json:"RecentAchievements"`
502-
LastGame GetUserSummaryLastGame `json:"LastGame"`
503502
}
504503

505504
type GetUserSummaryLastActivity struct {
@@ -543,24 +542,6 @@ type GetUserSummaryRecentAchievements struct {
543542
HardcoreAchieved int `json:"HardcoreAchieved"`
544543
}
545544

546-
type GetUserSummaryLastGame struct {
547-
ID int `json:"ID"`
548-
Title string `json:"Title"`
549-
ConsoleID int `json:"ConsoleID"`
550-
ConsoleName string `json:"ConsoleName"`
551-
ForumTopicID int `json:"ForumTopicID"`
552-
Flags int `json:"Flags"`
553-
ImageIcon string `json:"ImageIcon"`
554-
ImageTitle string `json:"ImageTitle"`
555-
ImageIngame string `json:"ImageIngame"`
556-
ImageBoxArt string `json:"ImageBoxArt"`
557-
Publisher string `json:"Publisher"`
558-
Developer string `json:"Developer"`
559-
Genre string `json:"Genre"`
560-
Released LongMonthDate `json:"Released"`
561-
IsFinal int `json:"IsFinal"`
562-
}
563-
564545
type GetUserCompletedGamesParameters struct {
565546
// The target username
566547
Username string

0 commit comments

Comments
 (0)