From 8a84ea789ead7bacb744eb8516d812502f97fd94 Mon Sep 17 00:00:00 2001 From: Matheus Pimenta Date: Sat, 6 Dec 2025 17:37:06 +0000 Subject: [PATCH] Fix docs and tests for list rikishi changes APIs Signed-off-by: Matheus Pimenta --- Makefile | 2 +- list_measurement_changes.go | 3 - list_rikishi_changes.go | 4 +- .../list_measurement_changes_test.go | 70 +++++++++++++----- tests/integration/list_rank_changes_test.go | 72 +++++++++++++------ .../integration/list_shikona_changes_test.go | 66 +++++++++++------ 6 files changed, 152 insertions(+), 65 deletions(-) diff --git a/Makefile b/Makefile index 0e01c99..058187e 100644 --- a/Makefile +++ b/Makefile @@ -4,4 +4,4 @@ test: .PHONY: test-integration test-integration: - cd tests/integration; go test -v ./... + cd tests/integration; go test -v -count=1 ./... diff --git a/list_measurement_changes.go b/list_measurement_changes.go index 28e37b3..af76197 100644 --- a/list_measurement_changes.go +++ b/list_measurement_changes.go @@ -5,9 +5,6 @@ import "context" // ListMeasurementChangesAPI defines the methods available for listing rikishi measurement changes across bashos. type ListMeasurementChangesAPI interface { // ListMeasurementChanges calls the GET /api/measurements endpoint. - // - // Documented bugs: - // - The API is ignoring the bashoId input. Measurement changes are returned for all bashos instead of the specified one. ListMeasurementChanges(ctx context.Context, req ListRikishiChangesRequest) ([]Measurement, error) } diff --git a/list_rikishi_changes.go b/list_rikishi_changes.go index 7c997af..4d044e3 100644 --- a/list_rikishi_changes.go +++ b/list_rikishi_changes.go @@ -8,8 +8,8 @@ import ( // ListRikishiChangesRequest represents a request to list Rikishi changes with optional filters. type ListRikishiChangesRequest struct { - RikishiID int `json:"rikishiId,omitempty" jsonschema:"The ID of the rikishi (sumo wrestler) whose changes are to be listed."` - BashoID *BashoID `json:"bashoId,omitempty" jsonschema:"The ID of the basho (sumo tournament) for which rikishi (sumo wrestler) changes are to be listed."` + 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."` + 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."` 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'."` } diff --git a/tests/integration/list_measurement_changes_test.go b/tests/integration/list_measurement_changes_test.go index 77766fe..0da4748 100644 --- a/tests/integration/list_measurement_changes_test.go +++ b/tests/integration/list_measurement_changes_test.go @@ -10,28 +10,62 @@ import ( ) func TestIntegration_ListMeasurementChanges(t *testing.T) { - g := NewWithT(t) - client := sumoapi.New() - resp, err := client.ListMeasurementChanges(context.Background(), sumoapi.ListRikishiChangesRequest{ - RikishiID: 3081, // Hakuho - BashoID: &sumoapi.BashoID{ - Year: 2021, - Month: 3, - }, + t.Run("for rikishi", func(t *testing.T) { + g := NewWithT(t) + + resp, err := client.ListMeasurementChanges(context.Background(), sumoapi.ListRikishiChangesRequest{ + RikishiID: 3081, // Hakuho + }) + + g.Expect(err).ToNot(HaveOccurred()) + g.Expect(resp).ToNot(BeNil()) + g.Expect(resp).To(HaveLen(15)) + + expectedBashoID := sumoapi.BashoID{Year: 2021, Month: 3} + + g.Expect(resp[0].ID).To(Equal(sumoapi.RikishiChangeID{BashoID: expectedBashoID, RikishiID: 3081})) + g.Expect(resp[0].BashoID).To(Equal(expectedBashoID)) + g.Expect(resp[0].RikishiID).To(Equal(3081)) + g.Expect(resp[0].Height).To(Equal(192.0)) + g.Expect(resp[0].Weight).To(Equal(151.0)) + + expectedBashoID = sumoapi.BashoID{Year: 2001, Month: 3} + + g.Expect(resp[14].ID).To(Equal(sumoapi.RikishiChangeID{BashoID: expectedBashoID, RikishiID: 3081})) + g.Expect(resp[14].BashoID).To(Equal(expectedBashoID)) + g.Expect(resp[14].RikishiID).To(Equal(3081)) + g.Expect(resp[14].Height).To(Equal(180.0)) + g.Expect(resp[14].Weight).To(Equal(80.0)) }) - g.Expect(err).ToNot(HaveOccurred()) - g.Expect(resp).ToNot(BeNil()) - g.Expect(len(resp)).To(BeNumerically(">", 1)) // Bug: The bashoId filter is not working. + t.Run("for basho", func(t *testing.T) { + g := NewWithT(t) + + bashoID := sumoapi.BashoID{ + Year: 2025, + Month: 9, + } + + resp, err := client.ListMeasurementChanges(context.Background(), sumoapi.ListRikishiChangesRequest{ + BashoID: &bashoID, + }) - expectedBashoID := sumoapi.BashoID{Year: 2021, Month: 3} + g.Expect(err).ToNot(HaveOccurred()) + g.Expect(resp).ToNot(BeNil()) + g.Expect(resp).To(HaveLen(4)) - hakuho := resp[0] - g.Expect(hakuho.ID).To(Equal(sumoapi.RikishiChangeID{BashoID: expectedBashoID, RikishiID: 3081})) - g.Expect(hakuho.BashoID).To(Equal(expectedBashoID)) - g.Expect(hakuho.RikishiID).To(Equal(3081)) - g.Expect(hakuho.Height).To(Equal(192.0)) - g.Expect(hakuho.Weight).To(Equal(151.0)) + g.Expect(resp[0].ID).To(Equal(sumoapi.RikishiChangeID{BashoID: bashoID, RikishiID: 9098})) + g.Expect(resp[0].BashoID).To(Equal(bashoID)) + g.Expect(resp[0].RikishiID).To(Equal(9098)) + g.Expect(resp[0].Height).To(Equal(178.0)) + g.Expect(resp[0].Weight).To(Equal(119.0)) + + g.Expect(resp[3].ID).To(Equal(sumoapi.RikishiChangeID{BashoID: bashoID, RikishiID: 9101})) + g.Expect(resp[3].BashoID).To(Equal(bashoID)) + g.Expect(resp[3].RikishiID).To(Equal(9101)) + g.Expect(resp[3].Height).To(Equal(175.0)) + g.Expect(resp[3].Weight).To(Equal(117.0)) + }) } diff --git a/tests/integration/list_rank_changes_test.go b/tests/integration/list_rank_changes_test.go index 33708dd..f48ba90 100644 --- a/tests/integration/list_rank_changes_test.go +++ b/tests/integration/list_rank_changes_test.go @@ -10,30 +10,62 @@ import ( ) func TestIntegration_ListRankChanges(t *testing.T) { - g := NewWithT(t) - client := sumoapi.New() - // Here we test a specific Rikishi that had rank changes to make sure the API - // is returning exactly one change when filtering by RikishiID and BashoID. - resp, err := client.ListRankChanges(context.Background(), sumoapi.ListRikishiChangesRequest{ - RikishiID: 3081, // Hakuho - BashoID: &sumoapi.BashoID{ - Year: 2021, - Month: 9, - }, + t.Run("for rikishi", func(t *testing.T) { + g := NewWithT(t) + + resp, err := client.ListRankChanges(context.Background(), sumoapi.ListRikishiChangesRequest{ + RikishiID: 3081, // Hakuho + }) + + g.Expect(err).ToNot(HaveOccurred()) + g.Expect(resp).ToNot(BeNil()) + g.Expect(resp).To(HaveLen(122)) + + expectedBashoID := sumoapi.BashoID{Year: 2021, Month: 9} + + g.Expect(resp[0].ID).To(Equal(sumoapi.RikishiChangeID{BashoID: expectedBashoID, RikishiID: 3081})) + g.Expect(resp[0].BashoID).To(Equal(expectedBashoID)) + g.Expect(resp[0].RikishiID).To(Equal(3081)) + g.Expect(resp[0].HumanReadableName).To(Equal("Yokozuna 1 East")) + g.Expect(resp[0].NumericName).To(Equal(101)) + + expectedBashoID = sumoapi.BashoID{Year: 2001, Month: 3} + + g.Expect(resp[121].ID).To(Equal(sumoapi.RikishiChangeID{BashoID: expectedBashoID, RikishiID: 3081})) + g.Expect(resp[121].BashoID).To(Equal(expectedBashoID)) + g.Expect(resp[121].RikishiID).To(Equal(3081)) + g.Expect(resp[121].HumanReadableName).To(Equal("Mae-zumo")) + g.Expect(resp[121].NumericName).To(Equal(2000)) }) - g.Expect(err).ToNot(HaveOccurred()) - g.Expect(resp).ToNot(BeNil()) - g.Expect(resp).To(HaveLen(1)) + t.Run("for basho", func(t *testing.T) { + g := NewWithT(t) + + bashoID := sumoapi.BashoID{ + Year: 2025, + Month: 9, + } + + resp, err := client.ListRankChanges(context.Background(), sumoapi.ListRikishiChangesRequest{ + BashoID: &bashoID, + }) + + g.Expect(err).ToNot(HaveOccurred()) + g.Expect(resp).ToNot(BeNil()) + g.Expect(resp).To(HaveLen(611)) - expectedBashoID := sumoapi.BashoID{Year: 2021, Month: 9} + g.Expect(resp[0].ID).To(Equal(sumoapi.RikishiChangeID{BashoID: bashoID, RikishiID: 8850})) + g.Expect(resp[0].BashoID).To(Equal(bashoID)) + g.Expect(resp[0].RikishiID).To(Equal(8850)) + g.Expect(resp[0].HumanReadableName).To(Equal("Yokozuna 1 East")) + g.Expect(resp[0].NumericName).To(Equal(101)) - hakuho := resp[0] - g.Expect(hakuho.ID).To(Equal(sumoapi.RikishiChangeID{BashoID: expectedBashoID, RikishiID: 3081})) - g.Expect(hakuho.BashoID).To(Equal(expectedBashoID)) - g.Expect(hakuho.RikishiID).To(Equal(3081)) - g.Expect(hakuho.HumanReadableName).To(Equal("Yokozuna 1 East")) - g.Expect(hakuho.NumericName).To(Equal(101)) + g.Expect(resp[610].ID).To(Equal(sumoapi.RikishiChangeID{BashoID: bashoID, RikishiID: 9101})) + g.Expect(resp[610].BashoID).To(Equal(bashoID)) + g.Expect(resp[610].RikishiID).To(Equal(9101)) + g.Expect(resp[610].HumanReadableName).To(Equal("Jonokuchi 26 East")) + g.Expect(resp[610].NumericName).To(Equal(1026)) + }) } diff --git a/tests/integration/list_shikona_changes_test.go b/tests/integration/list_shikona_changes_test.go index 57a4fe1..a0e9d8a 100644 --- a/tests/integration/list_shikona_changes_test.go +++ b/tests/integration/list_shikona_changes_test.go @@ -10,30 +10,54 @@ import ( ) func TestIntegration_ListShikonaChanges(t *testing.T) { - g := NewWithT(t) - client := sumoapi.New() - // Here we test a specific Rikishi that had shikona changes to make sure the API - // is returning exactly one change when filtering by RikishiID and BashoID. - resp, err := client.ListShikonaChanges(context.Background(), sumoapi.ListRikishiChangesRequest{ - RikishiID: 8857, // Yoshinofuji - BashoID: &sumoapi.BashoID{ - Year: 2025, - Month: 11, - }, - }) + t.Run("for rikishi", func(t *testing.T) { + g := NewWithT(t) - g.Expect(err).ToNot(HaveOccurred()) - g.Expect(resp).ToNot(BeNil()) - g.Expect(resp).To(HaveLen(1)) + resp, err := client.ListShikonaChanges(context.Background(), sumoapi.ListRikishiChangesRequest{ + RikishiID: 3081, // Hakuho + }) - expectedBashoID := sumoapi.BashoID{Year: 2025, Month: 11} + g.Expect(err).ToNot(HaveOccurred()) + g.Expect(resp).ToNot(BeNil()) + g.Expect(resp).To(HaveLen(1)) - yoshinofuji := resp[0] - g.Expect(yoshinofuji.ID).To(Equal(sumoapi.RikishiChangeID{BashoID: expectedBashoID, RikishiID: 8857})) - g.Expect(yoshinofuji.BashoID).To(Equal(expectedBashoID)) - g.Expect(yoshinofuji.RikishiID).To(Equal(8857)) - g.Expect(yoshinofuji.ShikonaEnglish).To(Equal("Yoshinofuji")) - g.Expect(yoshinofuji.ShikonaJapanese).To(Equal("義ノ富士 直哉")) + expectedBashoID := sumoapi.BashoID{Year: 2001, Month: 3} + + g.Expect(resp[0].ID).To(Equal(sumoapi.RikishiChangeID{BashoID: expectedBashoID, RikishiID: 3081})) + g.Expect(resp[0].BashoID).To(Equal(expectedBashoID)) + g.Expect(resp[0].RikishiID).To(Equal(3081)) + g.Expect(resp[0].ShikonaEnglish).To(Equal("Hakuho Sho")) + g.Expect(resp[0].ShikonaJapanese).To(Equal("")) + }) + + t.Run("for basho", func(t *testing.T) { + g := NewWithT(t) + + bashoID := sumoapi.BashoID{ + Year: 2025, + Month: 9, + } + + resp, err := client.ListShikonaChanges(context.Background(), sumoapi.ListRikishiChangesRequest{ + BashoID: &bashoID, + }) + + g.Expect(err).ToNot(HaveOccurred()) + g.Expect(resp).ToNot(BeNil()) + g.Expect(resp).To(HaveLen(10)) + + g.Expect(resp[0].ID).To(Equal(sumoapi.RikishiChangeID{BashoID: bashoID, RikishiID: 8859})) + g.Expect(resp[0].BashoID).To(Equal(bashoID)) + g.Expect(resp[0].RikishiID).To(Equal(8859)) + g.Expect(resp[0].ShikonaEnglish).To(Equal("Asasuiryu")) + g.Expect(resp[0].ShikonaJapanese).To(Equal("朝翠龍 涼馬")) + + g.Expect(resp[9].ID).To(Equal(sumoapi.RikishiChangeID{BashoID: bashoID, RikishiID: 594})) + g.Expect(resp[9].BashoID).To(Equal(bashoID)) + g.Expect(resp[9].RikishiID).To(Equal(594)) + g.Expect(resp[9].ShikonaEnglish).To(Equal("Moriurara")) + g.Expect(resp[9].ShikonaJapanese).To(Equal("森麗(もりうらら)")) + }) }