Skip to content

Commit

Permalink
Merge pull request #34 from codecrafters-io/add-command-param
Browse files Browse the repository at this point in the history
Refactor submission creation in submit.go and test.go
  • Loading branch information
rohitpaulk authored Jul 3, 2024
2 parents 24cf378 + 7dde834 commit a0a96ed
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion internal/commands/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func SubmitCommand(ctx context.Context) (err error) {

logger.Debug().Msgf("creating submission for %s", commitSha)

createSubmissionResponse, err := codecraftersClient.CreateSubmission(codecraftersRemote.CodecraftersRepositoryId(), commitSha)
createSubmissionResponse, err := codecraftersClient.CreateSubmission(codecraftersRemote.CodecraftersRepositoryId(), commitSha, "submit")
if err != nil {
return fmt.Errorf("create submission: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/commands/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func TestCommand(ctx context.Context) (err error) {

logger.Debug().Msgf("creating submission for %s", tempCommitSha)

createSubmissionResponse, err := codecraftersClient.CreateSubmission(codecraftersRemote.CodecraftersRepositoryId(), tempCommitSha)
createSubmissionResponse, err := codecraftersClient.CreateSubmission(codecraftersRemote.CodecraftersRepositoryId(), tempCommitSha, "test")
if err != nil {
return fmt.Errorf("create submission: %w", err)
}
Expand Down
8 changes: 4 additions & 4 deletions internal/utils/codecrafters_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ func (c CodecraftersClient) headers() map[string]string {
}
}

func (c CodecraftersClient) CreateSubmission(repositoryId string, commitSha string) (CreateSubmissionResponse, error) {
func (c CodecraftersClient) CreateSubmission(repositoryId string, commitSha string, command string) (CreateSubmissionResponse, error) {
response, err := grequests.Post(c.ServerUrl+"/services/cli/create_submission", &grequests.RequestOptions{
JSON: map[string]interface{}{
"repository_id": repositoryId,
"commit_sha": commitSha,
"should_auto_advance": false,
"repository_id": repositoryId,
"commit_sha": commitSha,
"command": command,
},
Headers: c.headers(),
})
Expand Down

0 comments on commit a0a96ed

Please sign in to comment.