Skip to content

Commit

Permalink
Merge pull request #441 from Shopify/fixing_windows_tests
Browse files Browse the repository at this point in the history
Fixing strict paths on windows
  • Loading branch information
tanema authored Aug 21, 2017
2 parents 160d752 + 42dd33d commit d22d816
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions kit/asset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package kit

import (
"encoding/base64"
"path/filepath"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -99,7 +100,7 @@ func TestLoadAssetsFromDirectory(t *testing.T) {
assets, err := loadAssetsFromDirectory(kittest.ProjectFiles[0], "", func(path string) bool { return false })
assert.Equal(t, "Path is not a directory", err.Error())
assets, err = loadAssetsFromDirectory(kittest.FixtureProjectPath, "", func(path string) bool {
return path != "assets/application.js"
return path != filepath.Join("assets","application.js")
})
assert.Nil(t, err)
assert.Equal(t, []Asset{{
Expand All @@ -121,7 +122,7 @@ func TestLoadAsset(t *testing.T) {
defer kittest.Cleanup()

asset, err := loadAsset(kittest.FixtureProjectPath, kittest.ProjectFiles[0])
assert.Equal(t, kittest.ProjectFiles[0], asset.Key)
assert.Equal(t, filepath.ToSlash(kittest.ProjectFiles[0]), asset.Key)
assert.Equal(t, true, asset.IsValid())
assert.Equal(t, "this is js content", asset.Value)
assert.Nil(t, err)
Expand Down
2 changes: 1 addition & 1 deletion kit/environments.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func searchConfigPath(configPath string) (string, string, error) {
name := filename[0 : len(filename)-len(filepath.Ext(filename))]
for _, ext := range supportedExts {
foundPath := filepath.Join(dir, name+"."+ext)
if _, err := os.Stat(foundPath); err == nil {
if _, err := os.Stat(foundPath); err == nil && "."+ext == filepath.Ext(filename) {
return foundPath, ext, nil
}
}
Expand Down
4 changes: 2 additions & 2 deletions kit/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func pathInProject(root, filename string) bool {
func isProjectDirectory(root, filename string) bool {
filename = strings.TrimPrefix(
filepath.ToSlash(filepath.Clean(filename)),
filepath.Clean(root)+"/",
filepath.ToSlash(filepath.Clean(root)+"/"),
)

for _, dir := range assetLocations {
Expand All @@ -40,7 +40,7 @@ func isProjectDirectory(root, filename string) bool {
func pathToProject(root, filename string) string {
filename = strings.TrimPrefix(
filepath.ToSlash(filepath.Clean(filename)),
filepath.Clean(root)+"/",
filepath.ToSlash(filepath.Clean(root)+"/"),
)

for _, dir := range assetLocations {
Expand Down
2 changes: 1 addition & 1 deletion kit/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

var (
// ThemeKitVersion is the version build of the library
ThemeKitVersion, _ = version.NewVersion("0.7.1")
ThemeKitVersion, _ = version.NewVersion("0.7.2")
// ThemeKitReleasesURL is the url that fetches all versions of themekit used for.
// updating themekit. Change this for testing reasons.
ThemeKitReleasesURL = "https://shopify-themekit.s3.amazonaws.com/releases/all.json"
Expand Down

0 comments on commit d22d816

Please sign in to comment.