Skip to content

Commit

Permalink
Rename GetTrack() to GetTrackById()
Browse files Browse the repository at this point in the history
Signed-off-by: Raphaël Pinson <[email protected]>
  • Loading branch information
raphink committed Sep 11, 2024
1 parent eb0310a commit 7e0e0c1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions instruqt/track.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ type Review struct {
Updated_At time.Time `json:"updated_at"` // The timestamp when the review was last updated.
}

// GetTrack retrieves a track from Instruqt using its unique track ID.
// GetTrackById retrieves a track from Instruqt using its unique track ID.
//
// Parameters:
// - trackId: The unique identifier of the track to retrieve.
//
// Returns:
// - Track: The track details if found.
// - error: Any error encountered while retrieving the track.
func (c *Client) GetTrack(trackId string) (t Track, err error) {
func (c *Client) GetTrackById(trackId string) (t Track, err error) {
if trackId == "" {
return t, nil
}
Expand All @@ -119,7 +119,7 @@ func (c *Client) GetTrack(trackId string) (t Track, err error) {
return q.Track, nil
}

// GetUserTrack retrieves a track for a specific user, including its challenges,
// GetUserTrackById retrieves a track for a specific user, including its challenges,
// using the user's ID and the track's ID.
//
// Parameters:
Expand All @@ -129,7 +129,7 @@ func (c *Client) GetTrack(trackId string) (t Track, err error) {
// Returns:
// - SandboxTrack: The track details with challenges if found.
// - error: Any error encountered while retrieving the track.
func (c *Client) GetUserTrack(userId string, trackId string) (t SandboxTrack, err error) {
func (c *Client) GetUserTrackById(userId string, trackId string) (t SandboxTrack, err error) {
if trackId == "" {
return t, nil
}
Expand Down Expand Up @@ -185,7 +185,7 @@ func (c *Client) GetTrackBySlug(trackSlug string) (t Track, err error) {
// - Challenge: The first unlocked challenge found.
// - error: Any error encountered while retrieving the challenge.
func (c *Client) GetTrackUnlockedChallenge(userId string, trackId string) (challenge Challenge, err error) {
track, err := c.GetUserTrack(userId, trackId)
track, err := c.GetUserTrackById(userId, trackId)
if err != nil {
return challenge, fmt.Errorf("[instruqt.GetTrackUnlockedChallenge] failed to get user track: %v", err)
}
Expand Down
8 changes: 4 additions & 4 deletions instruqt/track_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/stretchr/testify/mock"
)

func TestGetTrack(t *testing.T) {
func TestGetTrackById(t *testing.T) {
mockClient := new(MockGraphQLClient)
client := &Client{
GraphQLClient: mockClient,
Expand All @@ -30,14 +30,14 @@ func TestGetTrack(t *testing.T) {
*q = queryResult
}).Return(nil)

track, err := client.GetTrack(trackID)
track, err := client.GetTrackById(trackID)

assert.NoError(t, err)
assert.Equal(t, expectedTrack, track)
mockClient.AssertExpectations(t)
}

func TestGetUserTrack(t *testing.T) {
func TestGetUserTrackById(t *testing.T) {
mockClient := new(MockGraphQLClient)
client := &Client{
GraphQLClient: mockClient,
Expand All @@ -61,7 +61,7 @@ func TestGetUserTrack(t *testing.T) {
*q = queryResult
}).Return(nil)

track, err := client.GetUserTrack(userID, trackID)
track, err := client.GetUserTrackById(userID, trackID)

assert.NoError(t, err)
assert.Equal(t, expectedTrack, track)
Expand Down

0 comments on commit 7e0e0c1

Please sign in to comment.