-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve file name matching when determining parser for value of --pro…
…cfile flag Fixes #6
- Loading branch information
Showing
7 changed files
with
94 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
redis: bin/redis-server conf/redis.conf | ||
server: php -S localhost:8080 app/web/index.php | ||
selenium: java -jar /usr/local/bin/selenium-server-standalone.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Procfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
processes: | ||
redis: bin/redis-server conf/redis.conf | ||
server: "php -S localhost:8080 app/web/index.php" | ||
selenium: "java -jar /usr/local/bin/selenium-server-standalone.jar" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../Procfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../Proxfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/fgrosse/prox" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
"go.uber.org/zap/zaptest" | ||
"os" | ||
"testing" | ||
) | ||
|
||
func TestParseProcessesFile(t *testing.T) { | ||
cases := map[string]struct { | ||
dir string | ||
path string | ||
}{ | ||
"default Procfile": {dir: "_testdata/default-to-Procfile"}, | ||
"default Proxfile": {dir: "_testdata/default-to-Proxfile"}, | ||
"Proxfile": {dir: "_testdata", path: "Proxfile"}, | ||
"Procfile": {path: "_testdata/Procfile"}, | ||
"Procfile.dev": {path: "_testdata/Procfile.dev"}, | ||
} | ||
|
||
for name, c := range cases { | ||
t.Run(name, func(t *testing.T) { | ||
logger = zaptest.NewLogger(t) | ||
env := prox.Environment{} | ||
|
||
if c.dir != "" { | ||
changeDirectory(t, c.dir) | ||
} | ||
|
||
pp, err := processes(env, c.path) | ||
require.NoError(t, err) | ||
assert.Len(t, pp, 3) | ||
}) | ||
} | ||
} | ||
|
||
func changeDirectory(t *testing.T, dir string) { | ||
t.Helper() | ||
|
||
originalDir, err := os.Getwd() | ||
if err != nil { | ||
t.Fatalf("Failed to get current directory: %v", err) | ||
} | ||
|
||
err = os.Chdir(dir) | ||
require.NoError(t, err) | ||
|
||
t.Cleanup(func() { | ||
err := os.Chdir(originalDir) | ||
require.NoError(t, err) | ||
}) | ||
} |