realize/exec_test.go

30 lines
578 B
Go

package main
import (
"testing"
"time"
)
func TestProject_GoCompile(t *testing.T) {
p := Project{}
stop := make(chan bool)
response := make(chan string)
result, err := p.goCompile(stop, []string{"echo"}, []string{"test"})
if err != nil {
t.Error("Unexpected", err)
}
go func() {
result, err = p.goCompile(stop, []string{"sleep"}, []string{"20s"})
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")
}
}