Skip to content

Commit 8a84ea7

Browse files
committed
Fix docs and tests for list rikishi changes APIs
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
1 parent 649b621 commit 8a84ea7

6 files changed

Lines changed: 152 additions & 65 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ test:
44

55
.PHONY: test-integration
66
test-integration:
7-
cd tests/integration; go test -v ./...
7+
cd tests/integration; go test -v -count=1 ./...

list_measurement_changes.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ import "context"
55
// ListMeasurementChangesAPI defines the methods available for listing rikishi measurement changes across bashos.
66
type ListMeasurementChangesAPI interface {
77
// ListMeasurementChanges calls the GET /api/measurements endpoint.
8-
//
9-
// Documented bugs:
10-
// - The API is ignoring the bashoId input. Measurement changes are returned for all bashos instead of the specified one.
118
ListMeasurementChanges(ctx context.Context, req ListRikishiChangesRequest) ([]Measurement, error)
129
}
1310

list_rikishi_changes.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88

99
// ListRikishiChangesRequest represents a request to list Rikishi changes with optional filters.
1010
type ListRikishiChangesRequest struct {
11-
RikishiID int `json:"rikishiId,omitempty" jsonschema:"The ID of the rikishi (sumo wrestler) whose changes are to be listed."`
12-
BashoID *BashoID `json:"bashoId,omitempty" jsonschema:"The ID of the basho (sumo tournament) for which rikishi (sumo wrestler) changes are to be listed."`
11+
RikishiID int `json:"rikishiId,omitempty" jsonschema:"The ID of the rikishi (sumo wrestler) whose changes are to be listed. Cannot be used together with bashoId."`
12+
BashoID *BashoID `json:"bashoId,omitempty" jsonschema:"The ID of the basho (sumo tournament) for which rikishi (sumo wrestler) changes are to be listed. Cannot be used together with rikishiId."`
1313
SortOrder string `json:"sortOrder,omitempty" jsonschema:"The order in which to sort the results by basho (sumo tournament). Valid values are 'asc' for ascending and 'desc' for descending. Default is 'desc'."`
1414
}
1515

tests/integration/list_measurement_changes_test.go

Lines changed: 52 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,62 @@ import (
1010
)
1111

1212
func TestIntegration_ListMeasurementChanges(t *testing.T) {
13-
g := NewWithT(t)
14-
1513
client := sumoapi.New()
1614

17-
resp, err := client.ListMeasurementChanges(context.Background(), sumoapi.ListRikishiChangesRequest{
18-
RikishiID: 3081, // Hakuho
19-
BashoID: &sumoapi.BashoID{
20-
Year: 2021,
21-
Month: 3,
22-
},
15+
t.Run("for rikishi", func(t *testing.T) {
16+
g := NewWithT(t)
17+
18+
resp, err := client.ListMeasurementChanges(context.Background(), sumoapi.ListRikishiChangesRequest{
19+
RikishiID: 3081, // Hakuho
20+
})
21+
22+
g.Expect(err).ToNot(HaveOccurred())
23+
g.Expect(resp).ToNot(BeNil())
24+
g.Expect(resp).To(HaveLen(15))
25+
26+
expectedBashoID := sumoapi.BashoID{Year: 2021, Month: 3}
27+
28+
g.Expect(resp[0].ID).To(Equal(sumoapi.RikishiChangeID{BashoID: expectedBashoID, RikishiID: 3081}))
29+
g.Expect(resp[0].BashoID).To(Equal(expectedBashoID))
30+
g.Expect(resp[0].RikishiID).To(Equal(3081))
31+
g.Expect(resp[0].Height).To(Equal(192.0))
32+
g.Expect(resp[0].Weight).To(Equal(151.0))
33+
34+
expectedBashoID = sumoapi.BashoID{Year: 2001, Month: 3}
35+
36+
g.Expect(resp[14].ID).To(Equal(sumoapi.RikishiChangeID{BashoID: expectedBashoID, RikishiID: 3081}))
37+
g.Expect(resp[14].BashoID).To(Equal(expectedBashoID))
38+
g.Expect(resp[14].RikishiID).To(Equal(3081))
39+
g.Expect(resp[14].Height).To(Equal(180.0))
40+
g.Expect(resp[14].Weight).To(Equal(80.0))
2341
})
2442

25-
g.Expect(err).ToNot(HaveOccurred())
26-
g.Expect(resp).ToNot(BeNil())
27-
g.Expect(len(resp)).To(BeNumerically(">", 1)) // Bug: The bashoId filter is not working.
43+
t.Run("for basho", func(t *testing.T) {
44+
g := NewWithT(t)
45+
46+
bashoID := sumoapi.BashoID{
47+
Year: 2025,
48+
Month: 9,
49+
}
50+
51+
resp, err := client.ListMeasurementChanges(context.Background(), sumoapi.ListRikishiChangesRequest{
52+
BashoID: &bashoID,
53+
})
2854

29-
expectedBashoID := sumoapi.BashoID{Year: 2021, Month: 3}
55+
g.Expect(err).ToNot(HaveOccurred())
56+
g.Expect(resp).ToNot(BeNil())
57+
g.Expect(resp).To(HaveLen(4))
3058

31-
hakuho := resp[0]
32-
g.Expect(hakuho.ID).To(Equal(sumoapi.RikishiChangeID{BashoID: expectedBashoID, RikishiID: 3081}))
33-
g.Expect(hakuho.BashoID).To(Equal(expectedBashoID))
34-
g.Expect(hakuho.RikishiID).To(Equal(3081))
35-
g.Expect(hakuho.Height).To(Equal(192.0))
36-
g.Expect(hakuho.Weight).To(Equal(151.0))
59+
g.Expect(resp[0].ID).To(Equal(sumoapi.RikishiChangeID{BashoID: bashoID, RikishiID: 9098}))
60+
g.Expect(resp[0].BashoID).To(Equal(bashoID))
61+
g.Expect(resp[0].RikishiID).To(Equal(9098))
62+
g.Expect(resp[0].Height).To(Equal(178.0))
63+
g.Expect(resp[0].Weight).To(Equal(119.0))
64+
65+
g.Expect(resp[3].ID).To(Equal(sumoapi.RikishiChangeID{BashoID: bashoID, RikishiID: 9101}))
66+
g.Expect(resp[3].BashoID).To(Equal(bashoID))
67+
g.Expect(resp[3].RikishiID).To(Equal(9101))
68+
g.Expect(resp[3].Height).To(Equal(175.0))
69+
g.Expect(resp[3].Weight).To(Equal(117.0))
70+
})
3771
}

tests/integration/list_rank_changes_test.go

Lines changed: 52 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,62 @@ import (
1010
)
1111

1212
func TestIntegration_ListRankChanges(t *testing.T) {
13-
g := NewWithT(t)
14-
1513
client := sumoapi.New()
1614

17-
// Here we test a specific Rikishi that had rank changes to make sure the API
18-
// is returning exactly one change when filtering by RikishiID and BashoID.
19-
resp, err := client.ListRankChanges(context.Background(), sumoapi.ListRikishiChangesRequest{
20-
RikishiID: 3081, // Hakuho
21-
BashoID: &sumoapi.BashoID{
22-
Year: 2021,
23-
Month: 9,
24-
},
15+
t.Run("for rikishi", func(t *testing.T) {
16+
g := NewWithT(t)
17+
18+
resp, err := client.ListRankChanges(context.Background(), sumoapi.ListRikishiChangesRequest{
19+
RikishiID: 3081, // Hakuho
20+
})
21+
22+
g.Expect(err).ToNot(HaveOccurred())
23+
g.Expect(resp).ToNot(BeNil())
24+
g.Expect(resp).To(HaveLen(122))
25+
26+
expectedBashoID := sumoapi.BashoID{Year: 2021, Month: 9}
27+
28+
g.Expect(resp[0].ID).To(Equal(sumoapi.RikishiChangeID{BashoID: expectedBashoID, RikishiID: 3081}))
29+
g.Expect(resp[0].BashoID).To(Equal(expectedBashoID))
30+
g.Expect(resp[0].RikishiID).To(Equal(3081))
31+
g.Expect(resp[0].HumanReadableName).To(Equal("Yokozuna 1 East"))
32+
g.Expect(resp[0].NumericName).To(Equal(101))
33+
34+
expectedBashoID = sumoapi.BashoID{Year: 2001, Month: 3}
35+
36+
g.Expect(resp[121].ID).To(Equal(sumoapi.RikishiChangeID{BashoID: expectedBashoID, RikishiID: 3081}))
37+
g.Expect(resp[121].BashoID).To(Equal(expectedBashoID))
38+
g.Expect(resp[121].RikishiID).To(Equal(3081))
39+
g.Expect(resp[121].HumanReadableName).To(Equal("Mae-zumo"))
40+
g.Expect(resp[121].NumericName).To(Equal(2000))
2541
})
2642

27-
g.Expect(err).ToNot(HaveOccurred())
28-
g.Expect(resp).ToNot(BeNil())
29-
g.Expect(resp).To(HaveLen(1))
43+
t.Run("for basho", func(t *testing.T) {
44+
g := NewWithT(t)
45+
46+
bashoID := sumoapi.BashoID{
47+
Year: 2025,
48+
Month: 9,
49+
}
50+
51+
resp, err := client.ListRankChanges(context.Background(), sumoapi.ListRikishiChangesRequest{
52+
BashoID: &bashoID,
53+
})
54+
55+
g.Expect(err).ToNot(HaveOccurred())
56+
g.Expect(resp).ToNot(BeNil())
57+
g.Expect(resp).To(HaveLen(611))
3058

31-
expectedBashoID := sumoapi.BashoID{Year: 2021, Month: 9}
59+
g.Expect(resp[0].ID).To(Equal(sumoapi.RikishiChangeID{BashoID: bashoID, RikishiID: 8850}))
60+
g.Expect(resp[0].BashoID).To(Equal(bashoID))
61+
g.Expect(resp[0].RikishiID).To(Equal(8850))
62+
g.Expect(resp[0].HumanReadableName).To(Equal("Yokozuna 1 East"))
63+
g.Expect(resp[0].NumericName).To(Equal(101))
3264

33-
hakuho := resp[0]
34-
g.Expect(hakuho.ID).To(Equal(sumoapi.RikishiChangeID{BashoID: expectedBashoID, RikishiID: 3081}))
35-
g.Expect(hakuho.BashoID).To(Equal(expectedBashoID))
36-
g.Expect(hakuho.RikishiID).To(Equal(3081))
37-
g.Expect(hakuho.HumanReadableName).To(Equal("Yokozuna 1 East"))
38-
g.Expect(hakuho.NumericName).To(Equal(101))
65+
g.Expect(resp[610].ID).To(Equal(sumoapi.RikishiChangeID{BashoID: bashoID, RikishiID: 9101}))
66+
g.Expect(resp[610].BashoID).To(Equal(bashoID))
67+
g.Expect(resp[610].RikishiID).To(Equal(9101))
68+
g.Expect(resp[610].HumanReadableName).To(Equal("Jonokuchi 26 East"))
69+
g.Expect(resp[610].NumericName).To(Equal(1026))
70+
})
3971
}

tests/integration/list_shikona_changes_test.go

Lines changed: 45 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,54 @@ import (
1010
)
1111

1212
func TestIntegration_ListShikonaChanges(t *testing.T) {
13-
g := NewWithT(t)
14-
1513
client := sumoapi.New()
1614

17-
// Here we test a specific Rikishi that had shikona changes to make sure the API
18-
// is returning exactly one change when filtering by RikishiID and BashoID.
19-
resp, err := client.ListShikonaChanges(context.Background(), sumoapi.ListRikishiChangesRequest{
20-
RikishiID: 8857, // Yoshinofuji
21-
BashoID: &sumoapi.BashoID{
22-
Year: 2025,
23-
Month: 11,
24-
},
25-
})
15+
t.Run("for rikishi", func(t *testing.T) {
16+
g := NewWithT(t)
2617

27-
g.Expect(err).ToNot(HaveOccurred())
28-
g.Expect(resp).ToNot(BeNil())
29-
g.Expect(resp).To(HaveLen(1))
18+
resp, err := client.ListShikonaChanges(context.Background(), sumoapi.ListRikishiChangesRequest{
19+
RikishiID: 3081, // Hakuho
20+
})
3021

31-
expectedBashoID := sumoapi.BashoID{Year: 2025, Month: 11}
22+
g.Expect(err).ToNot(HaveOccurred())
23+
g.Expect(resp).ToNot(BeNil())
24+
g.Expect(resp).To(HaveLen(1))
3225

33-
yoshinofuji := resp[0]
34-
g.Expect(yoshinofuji.ID).To(Equal(sumoapi.RikishiChangeID{BashoID: expectedBashoID, RikishiID: 8857}))
35-
g.Expect(yoshinofuji.BashoID).To(Equal(expectedBashoID))
36-
g.Expect(yoshinofuji.RikishiID).To(Equal(8857))
37-
g.Expect(yoshinofuji.ShikonaEnglish).To(Equal("Yoshinofuji"))
38-
g.Expect(yoshinofuji.ShikonaJapanese).To(Equal("義ノ富士 直哉"))
26+
expectedBashoID := sumoapi.BashoID{Year: 2001, Month: 3}
27+
28+
g.Expect(resp[0].ID).To(Equal(sumoapi.RikishiChangeID{BashoID: expectedBashoID, RikishiID: 3081}))
29+
g.Expect(resp[0].BashoID).To(Equal(expectedBashoID))
30+
g.Expect(resp[0].RikishiID).To(Equal(3081))
31+
g.Expect(resp[0].ShikonaEnglish).To(Equal("Hakuho Sho"))
32+
g.Expect(resp[0].ShikonaJapanese).To(Equal(""))
33+
})
34+
35+
t.Run("for basho", func(t *testing.T) {
36+
g := NewWithT(t)
37+
38+
bashoID := sumoapi.BashoID{
39+
Year: 2025,
40+
Month: 9,
41+
}
42+
43+
resp, err := client.ListShikonaChanges(context.Background(), sumoapi.ListRikishiChangesRequest{
44+
BashoID: &bashoID,
45+
})
46+
47+
g.Expect(err).ToNot(HaveOccurred())
48+
g.Expect(resp).ToNot(BeNil())
49+
g.Expect(resp).To(HaveLen(10))
50+
51+
g.Expect(resp[0].ID).To(Equal(sumoapi.RikishiChangeID{BashoID: bashoID, RikishiID: 8859}))
52+
g.Expect(resp[0].BashoID).To(Equal(bashoID))
53+
g.Expect(resp[0].RikishiID).To(Equal(8859))
54+
g.Expect(resp[0].ShikonaEnglish).To(Equal("Asasuiryu"))
55+
g.Expect(resp[0].ShikonaJapanese).To(Equal("朝翠龍 涼馬"))
56+
57+
g.Expect(resp[9].ID).To(Equal(sumoapi.RikishiChangeID{BashoID: bashoID, RikishiID: 594}))
58+
g.Expect(resp[9].BashoID).To(Equal(bashoID))
59+
g.Expect(resp[9].RikishiID).To(Equal(594))
60+
g.Expect(resp[9].ShikonaEnglish).To(Equal("Moriurara"))
61+
g.Expect(resp[9].ShikonaJapanese).To(Equal("森麗(もりうらら)"))
62+
})
3963
}

0 commit comments

Comments
 (0)