Skip to content

Commit

Permalink
Refactor submission creation in submit.go and test.go
Browse files Browse the repository at this point in the history
This commit refactors the submission creation in submit.go and test.go files. It adds a new parameter command to the CreateSubmission function in
codecrafters_client.go file. The command parameter is used to specify the type of submission, either "submit" or "test". This change allows for better code
organization and separation of concerns.

Commit message: "Refactor submission creation in submit.go and test.go"
  • Loading branch information
rohitpaulk committed Jul 3, 2024
1 parent 24cf378 commit 7dde834
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 7dde834

Please sign in to comment.