Skip to content

Commit a0a96ed

Browse files
authored
Merge pull request #34 from codecrafters-io/add-command-param
Refactor submission creation in submit.go and test.go
2 parents 24cf378 + 7dde834 commit a0a96ed

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

internal/commands/submit.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func SubmitCommand(ctx context.Context) (err error) {
9191

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

94-
createSubmissionResponse, err := codecraftersClient.CreateSubmission(codecraftersRemote.CodecraftersRepositoryId(), commitSha)
94+
createSubmissionResponse, err := codecraftersClient.CreateSubmission(codecraftersRemote.CodecraftersRepositoryId(), commitSha, "submit")
9595
if err != nil {
9696
return fmt.Errorf("create submission: %w", err)
9797
}

internal/commands/test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func TestCommand(ctx context.Context) (err error) {
105105

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

108-
createSubmissionResponse, err := codecraftersClient.CreateSubmission(codecraftersRemote.CodecraftersRepositoryId(), tempCommitSha)
108+
createSubmissionResponse, err := codecraftersClient.CreateSubmission(codecraftersRemote.CodecraftersRepositoryId(), tempCommitSha, "test")
109109
if err != nil {
110110
return fmt.Errorf("create submission: %w", err)
111111
}

internal/utils/codecrafters_client.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ func (c CodecraftersClient) headers() map[string]string {
8888
}
8989
}
9090

91-
func (c CodecraftersClient) CreateSubmission(repositoryId string, commitSha string) (CreateSubmissionResponse, error) {
91+
func (c CodecraftersClient) CreateSubmission(repositoryId string, commitSha string, command string) (CreateSubmissionResponse, error) {
9292
response, err := grequests.Post(c.ServerUrl+"/services/cli/create_submission", &grequests.RequestOptions{
9393
JSON: map[string]interface{}{
94-
"repository_id": repositoryId,
95-
"commit_sha": commitSha,
96-
"should_auto_advance": false,
94+
"repository_id": repositoryId,
95+
"commit_sha": commitSha,
96+
"command": command,
9797
},
9898
Headers: c.headers(),
9999
})

0 commit comments

Comments
 (0)