diff --git a/basho.go b/basho.go index 85983e6..050d47b 100644 --- a/basho.go +++ b/basho.go @@ -4,8 +4,28 @@ import ( "encoding/json" "fmt" "strconv" + "time" ) +// Basho represents a sumo tournament. +type Basho struct { + ID BashoID `json:"date" jsonschema:"The unique identifier for the basho (sumo tournament), in the format YYYYMM."` + StartDate *time.Time `json:"startDate,omitempty" jsonschema:"The starting date of the basho (sumo tournament)."` + EndDate *time.Time `json:"endDate,omitempty" jsonschema:"The ending date of the basho (sumo tournament)."` + Yusho []BashoPrize `json:"yusho,omitempty" jsonschema:"A list of yusho (tournament championship) prizes awarded to rikishi (sumo wrestlers) in the basho (sumo tournament)."` + SpecialPrizes []BashoPrize `json:"specialPrizes,omitempty" jsonschema:"A list of special prizes awarded to rikishi (sumo wrestlers) in the basho (sumo tournament)."` + Torikumi []Match `json:"torikumi,omitempty" jsonschema:"A torikumi (bout schedule) that took or will take place for a specific day of a specific division of the basho (sumo tournament)."` +} + +// BashoPrize represents a prize awarded to a rikishi in a basho. +// It can be a yusho or a special prize. +type BashoPrize struct { + Type string `json:"type" jsonschema:"The type of prize. When the prize is a yusho (tournament championship), the value is the name of the tournament division. When the prize is a special prize, the value is one of 'Shukun-sho' (outstanding performance), 'Kanto-sho' (fighting spirit), or 'Gino-sho' (technique)."` + RikishiID int `json:"rikishiId" jsonschema:"The unique identifier of the rikishi (sumo wrestler) who received the prize."` + ShikonaEnglish string `json:"shikonaEn,omitempty" jsonschema:"The shikona (ring name) of the rikishi (sumo wrestler) in English."` + ShikonaJapanese string `json:"shikonaJp,omitempty" jsonschema:"The shikona (ring name) of the rikishi (sumo wrestler) in Japanese."` +} + // BashoID represents the unique identifier for a basho. type BashoID struct { Year int diff --git a/client.go b/client.go index e61459d..8139430 100644 --- a/client.go +++ b/client.go @@ -17,6 +17,8 @@ type Client interface { GetRikishiStatsAPI ListRikishiMatchesAPI ListRikishiMatchesAgainstOpponentAPI + GetBashoAPI + GetBashoWithTorikumiAPI ListKimariteAPI ListKimariteMatchesAPI ListMeasurementChangesAPI diff --git a/get_basho.go b/get_basho.go new file mode 100644 index 0000000..2b6cacf --- /dev/null +++ b/get_basho.go @@ -0,0 +1,22 @@ +package sumoapi + +import ( + "context" + "fmt" +) + +// GetBashoAPI defines the methods available for retrieving a basho. +type GetBashoAPI interface { + // GetBasho calls the GET /api/basho/{bashoID} endpoint. + GetBasho(ctx context.Context, req GetBashoRequest) (*Basho, error) +} + +// GetBashoRequest represents the request parameters for the GetBasho method. +type GetBashoRequest struct { + BashoID BashoID `json:"bashoId" jsonschema:"The unique identifier of the basho (sumo tournament) to retrieve. Format: YYYYMM, e.g., 202401 for the January 2024 basho."` +} + +func (c *client) GetBasho(ctx context.Context, req GetBashoRequest) (*Basho, error) { + path := fmt.Sprintf("/basho/%s", req.BashoID.String()) + return getObject[Basho](ctx, c, path, nil) +} diff --git a/get_basho_test.go b/get_basho_test.go new file mode 100644 index 0000000..37bddf8 --- /dev/null +++ b/get_basho_test.go @@ -0,0 +1,219 @@ +package sumoapi_test + +import ( + "context" + "io" + "net/http" + "strings" + "testing" + + . "github.com/onsi/gomega" + + "github.com/sumo-mcp/sumoapi-go" +) + +func TestClient_GetBasho(t *testing.T) { + t.Run("get basho by ID", func(t *testing.T) { + g := NewWithT(t) + + mockResp := `{ + "date": "202501", + "startDate": "2025-01-12T00:00:00Z", + "endDate": "2025-01-26T00:00:00Z", + "yusho": [ + { + "type": "Makuuchi", + "rikishiId": 45, + "shikonaEn": "Terunofuji", + "shikonaJp": "照ノ富士" + } + ], + "specialPrizes": [ + { + "type": "Shukun-sho", + "rikishiId": 123, + "shikonaEn": "Takakeisho", + "shikonaJp": "貴景勝" + } + ] + }` + + transport := &mockTransport{ + validateRequest: func(req *http.Request) error { + g.Expect(req.Method).To(Equal(http.MethodGet)) + g.Expect(req.URL.Scheme).To(Equal("https")) + g.Expect(req.URL.Host).To(Equal("sumo-api.com")) + g.Expect(req.URL.Path).To(Equal("/api/basho/202501")) + g.Expect(req.URL.Query()).To(BeEmpty()) + return nil + }, + response: &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(strings.NewReader(mockResp)), + }, + } + + client := sumoapi.New(sumoapi.WithHTTPClient(&http.Client{Transport: transport})) + resp, err := client.GetBasho(context.Background(), sumoapi.GetBashoRequest{ + BashoID: sumoapi.BashoID{Year: 2025, Month: 1}, + }) + + g.Expect(err).ToNot(HaveOccurred()) + g.Expect(resp).ToNot(BeNil()) + g.Expect(resp.ID).To(Equal(sumoapi.BashoID{Year: 2025, Month: 1})) + g.Expect(resp.StartDate).ToNot(BeNil()) + g.Expect(resp.EndDate).ToNot(BeNil()) + g.Expect(resp.Yusho).To(HaveLen(1)) + g.Expect(resp.Yusho[0].Type).To(Equal("Makuuchi")) + g.Expect(resp.Yusho[0].RikishiID).To(Equal(45)) + g.Expect(resp.Yusho[0].ShikonaEnglish).To(Equal("Terunofuji")) + g.Expect(resp.SpecialPrizes).To(HaveLen(1)) + g.Expect(resp.SpecialPrizes[0].Type).To(Equal("Shukun-sho")) + g.Expect(resp.SpecialPrizes[0].RikishiID).To(Equal(123)) + }) + + t.Run("get basho with minimal data", func(t *testing.T) { + g := NewWithT(t) + + mockResp := `{ + "date": "199903" + }` + + transport := &mockTransport{ + validateRequest: func(req *http.Request) error { + g.Expect(req.URL.Path).To(Equal("/api/basho/199903")) + return nil + }, + response: &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(strings.NewReader(mockResp)), + }, + } + + client := sumoapi.New(sumoapi.WithHTTPClient(&http.Client{Transport: transport})) + resp, err := client.GetBasho(context.Background(), sumoapi.GetBashoRequest{ + BashoID: sumoapi.BashoID{Year: 1999, Month: 3}, + }) + + g.Expect(err).ToNot(HaveOccurred()) + g.Expect(resp).ToNot(BeNil()) + g.Expect(resp.ID).To(Equal(sumoapi.BashoID{Year: 1999, Month: 3})) + g.Expect(resp.StartDate).To(BeNil()) + g.Expect(resp.EndDate).To(BeNil()) + g.Expect(resp.Yusho).To(BeEmpty()) + g.Expect(resp.SpecialPrizes).To(BeEmpty()) + g.Expect(resp.Torikumi).To(BeEmpty()) + }) + + t.Run("get basho with torikumi", func(t *testing.T) { + g := NewWithT(t) + + mockResp := `{ + "date": "202501", + "torikumi": [ + { + "bashoId": "202501", + "division": "Makuuchi", + "day": 1, + "matchNo": 1, + "eastId": 45, + "eastShikona": "Terunofuji", + "eastRank": "Yokozuna 1 East", + "westId": 123, + "westShikona": "Takakeisho", + "westRank": "Ozeki 1 West", + "kimarite": "Yorikiri", + "winnerId": 45, + "winnerEn": "Terunofuji" + } + ] + }` + + transport := &mockTransport{ + response: &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(strings.NewReader(mockResp)), + }, + } + + client := sumoapi.New(sumoapi.WithHTTPClient(&http.Client{Transport: transport})) + resp, err := client.GetBasho(context.Background(), sumoapi.GetBashoRequest{ + BashoID: sumoapi.BashoID{Year: 2025, Month: 1}, + }) + + g.Expect(err).ToNot(HaveOccurred()) + g.Expect(resp).ToNot(BeNil()) + g.Expect(resp.Torikumi).To(HaveLen(1)) + g.Expect(resp.Torikumi[0].BashoID).To(Equal(sumoapi.BashoID{Year: 2025, Month: 1})) + g.Expect(resp.Torikumi[0].Division).To(Equal("Makuuchi")) + g.Expect(resp.Torikumi[0].Day).To(Equal(1)) + }) + + t.Run("context is propagated", func(t *testing.T) { + g := NewWithT(t) + + mockResp := `{ + "date": "202501" + }` + + type testKey struct{} + ctx := context.WithValue(context.Background(), testKey{}, "test-value") + + transport := &mockTransport{ + validateRequest: func(req *http.Request) error { + g.Expect(req.Context().Value(testKey{})).To(Equal("test-value")) + return nil + }, + response: &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(strings.NewReader(mockResp)), + }, + } + + client := sumoapi.New(sumoapi.WithHTTPClient(&http.Client{Transport: transport})) + _, err := client.GetBasho(ctx, sumoapi.GetBashoRequest{ + BashoID: sumoapi.BashoID{Year: 2025, Month: 1}, + }) + + g.Expect(err).ToNot(HaveOccurred()) + }) + + t.Run("http request error", func(t *testing.T) { + g := NewWithT(t) + + transport := &mockTransport{ + validateRequest: func(req *http.Request) error { + return http.ErrAbortHandler + }, + } + + client := sumoapi.New(sumoapi.WithHTTPClient(&http.Client{Transport: transport})) + resp, err := client.GetBasho(context.Background(), sumoapi.GetBashoRequest{ + BashoID: sumoapi.BashoID{Year: 2025, Month: 1}, + }) + + g.Expect(err).To(HaveOccurred()) + g.Expect(err.Error()).To(ContainSubstring("error making http request")) + g.Expect(resp).To(BeNil()) + }) + + t.Run("invalid JSON response", func(t *testing.T) { + g := NewWithT(t) + + transport := &mockTransport{ + response: &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(strings.NewReader("not valid json")), + }, + } + + client := sumoapi.New(sumoapi.WithHTTPClient(&http.Client{Transport: transport})) + resp, err := client.GetBasho(context.Background(), sumoapi.GetBashoRequest{ + BashoID: sumoapi.BashoID{Year: 2025, Month: 1}, + }) + + g.Expect(err).To(HaveOccurred()) + g.Expect(err.Error()).To(ContainSubstring("error unmarshaling response body")) + g.Expect(resp).To(BeNil()) + }) +} diff --git a/get_basho_with_torikumi.go b/get_basho_with_torikumi.go new file mode 100644 index 0000000..0aac0bb --- /dev/null +++ b/get_basho_with_torikumi.go @@ -0,0 +1,27 @@ +package sumoapi + +import ( + "context" + "fmt" +) + +// GetBashoWithTorikumiAPI defines the methods available for retrieving a basho. +type GetBashoWithTorikumiAPI interface { + // GetBashoWithTorikumi calls the GET /api/basho/{bashoID}/torikumi/{division}/{day} endpoint. + // + // Documented bugs: + // - There's a skew in match numbering: the number of the match in the match ID starts at 0, while the matchNo field starts at 1. + GetBashoWithTorikumi(ctx context.Context, req GetBashoWithTorikumiRequest) (*Basho, error) +} + +// GetBashoWithTorikumiRequest represents the request parameters for the GetBashoWithTorikumi method. +type GetBashoWithTorikumiRequest struct { + BashoID BashoID `json:"bashoId" jsonschema:"The unique identifier of the basho (sumo tournament) to retrieve. Format: YYYYMM, e.g., 202401 for the January 2024 basho."` + Division string `json:"division" jsonschema:"The basho (sumo tournament) division to retrieve matches for. Valid values are Makuuchi, Juryo, Makushita, Sandanme, Jonidan, Jonokuchi."` + Day int `json:"day" jsonschema:"The day of the basho (sumo tournament) to retrieve matches for. Values from 1 to 15 represent days, and 16 and above represent individual playoff matches."` +} + +func (c *client) GetBashoWithTorikumi(ctx context.Context, req GetBashoWithTorikumiRequest) (*Basho, error) { + path := fmt.Sprintf("/basho/%s/torikumi/%s/%d", req.BashoID.String(), req.Division, req.Day) + return getObject[Basho](ctx, c, path, nil) +} diff --git a/get_basho_with_torikumi_test.go b/get_basho_with_torikumi_test.go new file mode 100644 index 0000000..2c620a7 --- /dev/null +++ b/get_basho_with_torikumi_test.go @@ -0,0 +1,219 @@ +package sumoapi_test + +import ( + "context" + "io" + "net/http" + "strings" + "testing" + + . "github.com/onsi/gomega" + + "github.com/sumo-mcp/sumoapi-go" +) + +func TestClient_GetBashoWithTorikumi(t *testing.T) { + t.Run("get basho with torikumi", func(t *testing.T) { + g := NewWithT(t) + + mockResp := `{ + "date": "202501", + "startDate": "2025-01-12T00:00:00Z", + "endDate": "2025-01-26T00:00:00Z", + "torikumi": [ + { + "id": "202501-1-1-45-123", + "bashoId": "202501", + "division": "Makuuchi", + "day": 1, + "matchNo": 1, + "eastId": 45, + "eastShikona": "Terunofuji", + "eastRank": "Yokozuna 1 East", + "westId": 123, + "westShikona": "Takakeisho", + "westRank": "Ozeki 1 West", + "kimarite": "yorikiri", + "winnerId": 45, + "winnerEn": "Terunofuji", + "winnerJp": "照ノ富士" + } + ] + }` + + transport := &mockTransport{ + validateRequest: func(req *http.Request) error { + g.Expect(req.Method).To(Equal(http.MethodGet)) + g.Expect(req.URL.Scheme).To(Equal("https")) + g.Expect(req.URL.Host).To(Equal("sumo-api.com")) + g.Expect(req.URL.Path).To(Equal("/api/basho/202501/torikumi/Makuuchi/1")) + g.Expect(req.URL.Query()).To(BeEmpty()) + return nil + }, + response: &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(strings.NewReader(mockResp)), + }, + } + + client := sumoapi.New(sumoapi.WithHTTPClient(&http.Client{Transport: transport})) + resp, err := client.GetBashoWithTorikumi(context.Background(), sumoapi.GetBashoWithTorikumiRequest{ + BashoID: sumoapi.BashoID{Year: 2025, Month: 1}, + Division: "Makuuchi", + Day: 1, + }) + + g.Expect(err).ToNot(HaveOccurred()) + g.Expect(resp).ToNot(BeNil()) + g.Expect(resp.ID).To(Equal(sumoapi.BashoID{Year: 2025, Month: 1})) + g.Expect(resp.Torikumi).To(HaveLen(1)) + g.Expect(resp.Torikumi[0].ID).ToNot(BeNil()) + g.Expect(resp.Torikumi[0].ID.BashoID).To(Equal(sumoapi.BashoID{Year: 2025, Month: 1})) + g.Expect(resp.Torikumi[0].ID.Day).To(Equal(1)) + g.Expect(resp.Torikumi[0].ID.MatchNumber).To(Equal(1)) + g.Expect(resp.Torikumi[0].BashoID).To(Equal(sumoapi.BashoID{Year: 2025, Month: 1})) + g.Expect(resp.Torikumi[0].Division).To(Equal("Makuuchi")) + g.Expect(resp.Torikumi[0].Day).To(Equal(1)) + g.Expect(resp.Torikumi[0].MatchNumber).To(Equal(1)) + g.Expect(resp.Torikumi[0].EastID).To(Equal(45)) + g.Expect(resp.Torikumi[0].WestID).To(Equal(123)) + g.Expect(resp.Torikumi[0].Kimarite).To(Equal("yorikiri")) + g.Expect(resp.Torikumi[0].WinnerID).To(Equal(45)) + }) + + t.Run("get basho with torikumi for Juryo division", func(t *testing.T) { + g := NewWithT(t) + + mockResp := `{ + "date": "202501", + "torikumi": [] + }` + + transport := &mockTransport{ + validateRequest: func(req *http.Request) error { + g.Expect(req.URL.Path).To(Equal("/api/basho/202501/torikumi/Juryo/5")) + return nil + }, + response: &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(strings.NewReader(mockResp)), + }, + } + + client := sumoapi.New(sumoapi.WithHTTPClient(&http.Client{Transport: transport})) + resp, err := client.GetBashoWithTorikumi(context.Background(), sumoapi.GetBashoWithTorikumiRequest{ + BashoID: sumoapi.BashoID{Year: 2025, Month: 1}, + Division: "Juryo", + Day: 5, + }) + + g.Expect(err).ToNot(HaveOccurred()) + g.Expect(resp).ToNot(BeNil()) + g.Expect(resp.Torikumi).To(BeEmpty()) + }) + + t.Run("get basho with torikumi for playoff day", func(t *testing.T) { + g := NewWithT(t) + + mockResp := `{ + "date": "202501", + "torikumi": [] + }` + + transport := &mockTransport{ + validateRequest: func(req *http.Request) error { + g.Expect(req.URL.Path).To(Equal("/api/basho/202501/torikumi/Makuuchi/16")) + return nil + }, + response: &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(strings.NewReader(mockResp)), + }, + } + + client := sumoapi.New(sumoapi.WithHTTPClient(&http.Client{Transport: transport})) + resp, err := client.GetBashoWithTorikumi(context.Background(), sumoapi.GetBashoWithTorikumiRequest{ + BashoID: sumoapi.BashoID{Year: 2025, Month: 1}, + Division: "Makuuchi", + Day: 16, + }) + + g.Expect(err).ToNot(HaveOccurred()) + g.Expect(resp).ToNot(BeNil()) + }) + + t.Run("context is propagated", func(t *testing.T) { + g := NewWithT(t) + + mockResp := `{ + "date": "202501", + "torikumi": [] + }` + + type testKey struct{} + ctx := context.WithValue(context.Background(), testKey{}, "test-value") + + transport := &mockTransport{ + validateRequest: func(req *http.Request) error { + g.Expect(req.Context().Value(testKey{})).To(Equal("test-value")) + return nil + }, + response: &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(strings.NewReader(mockResp)), + }, + } + + client := sumoapi.New(sumoapi.WithHTTPClient(&http.Client{Transport: transport})) + _, err := client.GetBashoWithTorikumi(ctx, sumoapi.GetBashoWithTorikumiRequest{ + BashoID: sumoapi.BashoID{Year: 2025, Month: 1}, + Division: "Makuuchi", + Day: 1, + }) + + g.Expect(err).ToNot(HaveOccurred()) + }) + + t.Run("http request error", func(t *testing.T) { + g := NewWithT(t) + + transport := &mockTransport{ + validateRequest: func(req *http.Request) error { + return http.ErrAbortHandler + }, + } + + client := sumoapi.New(sumoapi.WithHTTPClient(&http.Client{Transport: transport})) + resp, err := client.GetBashoWithTorikumi(context.Background(), sumoapi.GetBashoWithTorikumiRequest{ + BashoID: sumoapi.BashoID{Year: 2025, Month: 1}, + Division: "Makuuchi", + Day: 1, + }) + + g.Expect(err).To(HaveOccurred()) + g.Expect(err.Error()).To(ContainSubstring("error making http request")) + g.Expect(resp).To(BeNil()) + }) + + t.Run("invalid JSON response", func(t *testing.T) { + g := NewWithT(t) + + transport := &mockTransport{ + response: &http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(strings.NewReader("not valid json")), + }, + } + + client := sumoapi.New(sumoapi.WithHTTPClient(&http.Client{Transport: transport})) + resp, err := client.GetBashoWithTorikumi(context.Background(), sumoapi.GetBashoWithTorikumiRequest{ + BashoID: sumoapi.BashoID{Year: 2025, Month: 1}, + Division: "Makuuchi", + Day: 1, + }) + + g.Expect(err).To(HaveOccurred()) + g.Expect(err.Error()).To(ContainSubstring("error unmarshaling response body")) + g.Expect(resp).To(BeNil()) + }) +} diff --git a/tests/integration/get_basho_test.go b/tests/integration/get_basho_test.go new file mode 100644 index 0000000..8b983ad --- /dev/null +++ b/tests/integration/get_basho_test.go @@ -0,0 +1,76 @@ +package integration_test + +import ( + "context" + "testing" + "time" + + . "github.com/onsi/gomega" + + "github.com/sumo-mcp/sumoapi-go" +) + +func TestIntegration_GetBasho(t *testing.T) { + g := NewWithT(t) + + client := sumoapi.New() + + bashoID := sumoapi.BashoID{Year: 2025, Month: 11} + resp, err := client.GetBasho(context.Background(), sumoapi.GetBashoRequest{ + BashoID: bashoID, + }) + + g.Expect(err).ToNot(HaveOccurred()) + g.Expect(resp).ToNot(BeNil()) + g.Expect(resp.ID).To(Equal(bashoID)) + + startDate, _ := time.Parse(time.RFC3339, "2025-11-09T00:00:00Z") + endDate, _ := time.Parse(time.RFC3339, "2025-11-23T00:00:00Z") + g.Expect(resp.StartDate).ToNot(BeNil()) + g.Expect(*resp.StartDate).To(Equal(startDate)) + g.Expect(resp.EndDate).ToNot(BeNil()) + g.Expect(*resp.EndDate).To(Equal(endDate)) + + g.Expect(resp.Yusho).To(HaveLen(6)) + g.Expect(resp.Yusho[0].Type).To(Equal("Makuuchi")) + g.Expect(resp.Yusho[0].RikishiID).To(Equal(8854)) + g.Expect(resp.Yusho[0].ShikonaEnglish).To(Equal("Aonishiki")) + g.Expect(resp.Yusho[0].ShikonaJapanese).To(Equal("安青錦 新大")) + + g.Expect(resp.Yusho[1].Type).To(Equal("Juryo")) + g.Expect(resp.Yusho[1].RikishiID).To(Equal(9051)) + g.Expect(resp.Yusho[1].ShikonaEnglish).To(Equal("Fujiryoga")) + + g.Expect(resp.Yusho[2].Type).To(Equal("Makushita")) + g.Expect(resp.Yusho[2].RikishiID).To(Equal(8865)) + + g.Expect(resp.Yusho[3].Type).To(Equal("Sandanme")) + g.Expect(resp.Yusho[3].RikishiID).To(Equal(9088)) + + g.Expect(resp.Yusho[4].Type).To(Equal("Jonidan")) + g.Expect(resp.Yusho[4].RikishiID).To(Equal(9099)) + + g.Expect(resp.Yusho[5].Type).To(Equal("Jonokuchi")) + g.Expect(resp.Yusho[5].RikishiID).To(Equal(228)) + + g.Expect(resp.SpecialPrizes).To(HaveLen(5)) + g.Expect(resp.SpecialPrizes[0].Type).To(Equal("Shukun-sho")) + g.Expect(resp.SpecialPrizes[0].RikishiID).To(Equal(8854)) + g.Expect(resp.SpecialPrizes[0].ShikonaEnglish).To(Equal("Aonishiki")) + + g.Expect(resp.SpecialPrizes[1].Type).To(Equal("Kanto-sho")) + g.Expect(resp.SpecialPrizes[1].RikishiID).To(Equal(7)) + g.Expect(resp.SpecialPrizes[1].ShikonaEnglish).To(Equal("Kirishima")) + + g.Expect(resp.SpecialPrizes[2].Type).To(Equal("Kanto-sho")) + g.Expect(resp.SpecialPrizes[2].RikishiID).To(Equal(11)) + g.Expect(resp.SpecialPrizes[2].ShikonaEnglish).To(Equal("Ichiyamamoto")) + + g.Expect(resp.SpecialPrizes[3].Type).To(Equal("Gino-sho")) + g.Expect(resp.SpecialPrizes[3].RikishiID).To(Equal(8854)) + g.Expect(resp.SpecialPrizes[3].ShikonaEnglish).To(Equal("Aonishiki")) + + g.Expect(resp.SpecialPrizes[4].Type).To(Equal("Gino-sho")) + g.Expect(resp.SpecialPrizes[4].RikishiID).To(Equal(8857)) + g.Expect(resp.SpecialPrizes[4].ShikonaEnglish).To(Equal("Yoshinofuji")) +} diff --git a/tests/integration/get_basho_with_torikumi_test.go b/tests/integration/get_basho_with_torikumi_test.go new file mode 100644 index 0000000..656f9fc --- /dev/null +++ b/tests/integration/get_basho_with_torikumi_test.go @@ -0,0 +1,77 @@ +package integration_test + +import ( + "context" + "testing" + "time" + + . "github.com/onsi/gomega" + + "github.com/sumo-mcp/sumoapi-go" +) + +func TestIntegration_GetBashoWithTorikumi(t *testing.T) { + g := NewWithT(t) + + client := sumoapi.New() + + bashoID := sumoapi.BashoID{Year: 2025, Month: 11} + resp, err := client.GetBashoWithTorikumi(context.Background(), sumoapi.GetBashoWithTorikumiRequest{ + BashoID: bashoID, + Division: "Makuuchi", + Day: 1, + }) + + g.Expect(err).ToNot(HaveOccurred()) + g.Expect(resp).ToNot(BeNil()) + g.Expect(resp.ID).To(Equal(bashoID)) + + startDate, _ := time.Parse(time.RFC3339, "2025-11-09T00:00:00Z") + endDate, _ := time.Parse(time.RFC3339, "2025-11-23T00:00:00Z") + g.Expect(resp.StartDate).ToNot(BeNil()) + g.Expect(*resp.StartDate).To(Equal(startDate)) + g.Expect(resp.EndDate).ToNot(BeNil()) + g.Expect(*resp.EndDate).To(Equal(endDate)) + + g.Expect(resp.Yusho).To(HaveLen(6)) + g.Expect(resp.SpecialPrizes).To(HaveLen(5)) + + g.Expect(resp.Torikumi).To(HaveLen(21)) + + match := resp.Torikumi[0] + g.Expect(match.ID).ToNot(BeNil()) + g.Expect(match.ID.BashoID).To(Equal(bashoID)) + g.Expect(match.ID.Day).To(Equal(1)) + g.Expect(match.ID.MatchNumber).To(Equal(0)) // Bug: The match number in the ID starts at 0. + g.Expect(match.ID.EastID).To(Equal(111)) + g.Expect(match.ID.WestID).To(Equal(164)) + g.Expect(match.BashoID).To(Equal(bashoID)) + g.Expect(match.Division).To(Equal("Makuuchi")) + g.Expect(match.Day).To(Equal(1)) + g.Expect(match.MatchNumber).To(Equal(1)) + g.Expect(match.EastID).To(Equal(111)) + g.Expect(match.EastShikona).To(Equal("Hitoshi")) + g.Expect(match.EastRank).To(Equal("Juryo 1 East")) + g.Expect(match.WestID).To(Equal(164)) + g.Expect(match.WestShikona).To(Equal("Asakoryu")) + g.Expect(match.WestRank).To(Equal("Maegashira 17 West")) + g.Expect(match.Kimarite).To(Equal("tsukidashi")) + g.Expect(match.WinnerID).To(Equal(164)) + g.Expect(match.WinnerEnglish).To(Equal("Asakoryu")) + g.Expect(match.WinnerJapanese).To(Equal("朝紅龍")) + + lastMatch := resp.Torikumi[20] + g.Expect(lastMatch.ID).ToNot(BeNil()) + g.Expect(lastMatch.ID.MatchNumber).To(Equal(20)) // Bug: The match number in the ID starts at 0. + g.Expect(lastMatch.MatchNumber).To(Equal(21)) + g.Expect(lastMatch.EastID).To(Equal(8850)) + g.Expect(lastMatch.EastShikona).To(Equal("Onosato")) + g.Expect(lastMatch.EastRank).To(Equal("Yokozuna 1 East")) + g.Expect(lastMatch.WestID).To(Equal(44)) + g.Expect(lastMatch.WestShikona).To(Equal("Takayasu")) + g.Expect(lastMatch.WestRank).To(Equal("Komusubi 1 West")) + g.Expect(lastMatch.Kimarite).To(Equal("yorikiri")) + g.Expect(lastMatch.WinnerID).To(Equal(8850)) + g.Expect(lastMatch.WinnerEnglish).To(Equal("Onosato")) + g.Expect(lastMatch.WinnerJapanese).To(Equal("大の里")) +}