Skip to content

Commit

Permalink
Refactor tests using encapsulated metadata path
Browse files Browse the repository at this point in the history
  • Loading branch information
jdsutherland committed Aug 28, 2018
1 parent fda69bf commit 2cf12a2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions workspace/exercise_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ func TestHasMetadata(t *testing.T) {
exerciseA := Exercise{Root: ws, Track: "bogus-track", Slug: "apple"}
exerciseB := Exercise{Root: ws, Track: "bogus-track", Slug: "banana"}

err = os.MkdirAll(filepath.Join(exerciseA.Filepath(), ignoreSubdir), os.FileMode(0755))
err = os.MkdirAll(filepath.Dir(exerciseA.MetadataFilepath()), os.FileMode(0755))
assert.NoError(t, err)
err = os.MkdirAll(filepath.Join(exerciseB.Filepath(), ignoreSubdir), os.FileMode(0755))
err = os.MkdirAll(filepath.Dir(exerciseB.MetadataFilepath()), os.FileMode(0755))
assert.NoError(t, err)

err = ioutil.WriteFile(exerciseA.MetadataFilepath(), []byte{}, os.FileMode(0600))
Expand Down
5 changes: 3 additions & 2 deletions workspace/workspace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"path/filepath"
"runtime"
"sort"
"strings"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -60,11 +61,11 @@ func TestWorkspaceExercises(t *testing.T) {
b2 := filepath.Join(tmpDir, "track-b", "exercise-two")

for _, path := range []string{a1, a2, b1, b2} {
path := filepath.Join(path, ignoreSubdir)
path := filepath.Dir(NewExerciseFromDir(path).MetadataFilepath())
err := os.MkdirAll(path, os.FileMode(0755))
assert.NoError(t, err)

if path != filepath.Join(a2, ignoreSubdir) {
if !strings.HasPrefix(path, a2) {
err = ioutil.WriteFile(filepath.Join(path, solutionFilename), []byte{}, os.FileMode(0600))
assert.NoError(t, err)
}
Expand Down

0 comments on commit 2cf12a2

Please sign in to comment.