diff --git a/api/iteration.go b/api/iteration.go index 8fd3fa53e..f0632c125 100644 --- a/api/iteration.go +++ b/api/iteration.go @@ -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) diff --git a/api/iteration_darwin_test.go b/api/iteration_darwin_test.go new file mode 100644 index 000000000..d910d354f --- /dev/null +++ b/api/iteration_darwin_test.go @@ -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) + } + } +} diff --git a/cmd/submit.go b/cmd/submit.go index 146101382..5ba006295 100644 --- a/cmd/submit.go +++ b/cmd/submit.go @@ -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. @@ -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")