-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
show error log on fail + some visual improvements
Closes: #2
- Loading branch information
Showing
35 changed files
with
4,698 additions
and
32 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,28 @@ | ||
# This is an example goreleaser.yaml file with some sane defaults. | ||
# Make sure to check the documentation at http://goreleaser.com | ||
before: | ||
hooks: | ||
# you may remove this if you don't use vgo | ||
- go mod download | ||
# you may remove this if you don't need go generate | ||
- go generate ./... | ||
builds: | ||
- env: | ||
- CGO_ENABLED=0 | ||
archives: | ||
- replacements: | ||
darwin: Darwin | ||
linux: Linux | ||
windows: Windows | ||
386: i386 | ||
amd64: x86_64 | ||
checksum: | ||
name_template: 'checksums.txt' | ||
snapshot: | ||
name_template: "{{ .Tag }}-next" | ||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- '^docs:' | ||
- '^test:' |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,12 +1,27 @@ | ||
delay=500 | ||
|
||
[[watch]] | ||
name = "linter" | ||
paths = ["vendor/github.com"] | ||
commands = ["sleep 1", "sleep 1", "ls /sfsdfsdf"] | ||
name = "tests" | ||
paths = ["printer", "watcher", "types"] | ||
commands = ["make test"] | ||
|
||
[[watch]] | ||
name = "tests" | ||
paths = ["."] | ||
name = "vet" | ||
paths = ["printer", "watcher", "types"] | ||
commands = ["make vet"] | ||
|
||
[[watch]] | ||
name = "lint" | ||
paths = ["printer", "watcher", "types"] | ||
commands = ["make lint"] | ||
|
||
[[watch]] | ||
name = "goimports" | ||
paths = ["printer", "watcher", "types"] | ||
commands = ["make imports"] | ||
|
||
[[watch]] | ||
name = "something" | ||
paths = ["vendor/github.com"] | ||
ignorePrefixes = ["vendor"] | ||
commands = ["sleep 5"] | ||
commands = ["sleep 1", "sleep 1", "ls /sfsdfsdf"] |
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,61 @@ | ||
package printer | ||
|
||
import ( | ||
"io/ioutil" | ||
"os" | ||
"testing" | ||
"time" | ||
|
||
"github.com/Enapiuz/multiwatch/watcher" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/mock" | ||
) | ||
|
||
type WatcherMock struct { | ||
mock.Mock | ||
} | ||
|
||
func (w *WatcherMock) Run(chan bool) { | ||
panic("implement me") | ||
} | ||
|
||
func (w *WatcherMock) GetStatus() string { | ||
return "status_log" | ||
} | ||
|
||
func (w *WatcherMock) GetErrors() string { | ||
return "error_log" | ||
} | ||
|
||
func TestNewPrinter(t *testing.T) { | ||
samplePrinter := NewPrinter() | ||
assert.Len(t, samplePrinter.watchers, 0) | ||
} | ||
|
||
func TestPrinter_RegisterWatchers(t *testing.T) { | ||
testPrinter := NewPrinter() | ||
dumbWatcher := &WatcherMock{} | ||
testPrinter.RegisterWatchers([]watcher.Interface{dumbWatcher}) | ||
assert.Len(t, testPrinter.watchers, 1) | ||
} | ||
|
||
func TestPrinter_Start(t *testing.T) { | ||
rescueStdout := os.Stdout | ||
r, w, _ := os.Pipe() | ||
os.Stdout = w | ||
|
||
testPrinter := NewPrinter() | ||
dumbWatcher := &WatcherMock{} | ||
testPrinter.RegisterWatchers([]watcher.Interface{dumbWatcher}) | ||
needReprint := make(chan bool) | ||
testPrinter.Start(needReprint) | ||
needReprint <- true | ||
|
||
time.Sleep(1 * time.Second) | ||
w.Close() | ||
out, _ := ioutil.ReadAll(r) | ||
os.Stdout = rescueStdout | ||
|
||
assert.Contains(t, string(out), "status_log") | ||
assert.Contains(t, string(out), "error_log") | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.