Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/iteration.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ func NewIteration(dir string, filenames []string) (*Iteration, error) {
// is still bad. Has the user modified their path in some way?
return nil, newIterationError(msgGenericPathError, iter.Dir)
}
iter.TrackID = segments[1]
iter.Problem = segments[2]
iter.TrackID = strings.ToLower(segments[1])
iter.Problem = strings.ToLower(segments[2])

for _, filename := range filenames {
fileContents, err := readFileAsUTF8String(filename)
Expand Down
38 changes: 38 additions & 0 deletions api/iteration_darwin_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package api

import (
"path/filepath"
"runtime"
"testing"
)

func TestNewIteration_CaseSensitive(t *testing.T) {
_, path, _, _ := runtime.Caller(0)
dir := filepath.Join(path, "..", "..", "fixtures", "iteration")

testCases := []map[string][]string{
{
"file": []string{filepath.Join(dir, "python", "leap", "one.py")},
},
{
"file": []string{filepath.Join(dir, "Python", "leap", "one.py")},
},
{
"file": []string{filepath.Join(dir, "Python", "Leap", "one.py")},
},
}

for _, testCase := range testCases {
iter, err := NewIteration(dir, testCase["file"])
if err != nil {
t.Fatal(err)
}

if iter.TrackID != "python" {
t.Errorf("Expected language to be python, was %s", iter.TrackID)
}
if iter.Problem != "leap" {
t.Errorf("Expected problem to be leap, was %s", iter.Problem)
}
}
}
4 changes: 2 additions & 2 deletions cmd/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (
"os"
"path/filepath"

"github.com/urfave/cli"
"github.com/exercism/cli/api"
"github.com/exercism/cli/config"
"github.com/exercism/cli/paths"
"github.com/urfave/cli"
)

// Submit posts an iteration to the API.
Expand Down Expand Up @@ -89,7 +89,7 @@ func Submit(ctx *cli.Context) error {

iteration, err := api.NewIteration(dir, files)
if err != nil {
log.Fatalf("Unable to submit - %s", err)
log.Fatalf("unable to submit - %s", err)
}
iteration.Key = c.APIKey
iteration.Comment = ctx.String("comment")
Expand Down