realize/exec_test.go

30 lines
577 B
Go
Raw Normal View History

package main
2017-10-15 19:35:50 +00:00
import (
"testing"
"time"
)
func TestProject_GoCompile(t *testing.T) {
p := Project{}
stop := make(chan bool)
response := make(chan string)
2017-10-15 20:15:50 +00:00
result, err := p.goCompile(stop, []string{"echo"}, []string{"test"})
2017-10-15 19:35:50 +00:00
if err != nil {
t.Error("Unexpected", err)
}
go func() {
2017-10-15 20:15:50 +00:00
result, err = p.goCompile(stop, []string{"sleep"}, []string{"20s"})
2017-10-15 19:35:50 +00:00
response <- result
}()
close(stop)
select {
case v := <-response:
2017-10-16 16:59:35 +00:00
if v != msgStop {
2017-10-15 19:35:50 +00:00
t.Error("Unexpected result", response)
}
case <-time.After(2 * time.Second):
t.Error("Channel doesn't works")
}
}