realize/exec_test.go

30 lines
578 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:
if v != "killed" {
t.Error("Unexpected result", response)
}
case <-time.After(2 * time.Second):
t.Error("Channel doesn't works")
}
}