@@ -6,12 +6,16 @@ import (
66 "time"
77)
88
9- const SingleConcurrent = 1
9+ func Test_NewRuntime (t * testing.T ) {
10+ runtime := NewRuntime (Node {Name : "test" }, Node {Name : "test2" })
11+
12+ assert .Len (t , runtime .Nodes , 3 )
13+ }
1014
1115func TestRuntime_Start (t * testing.T ) {
1216 s := getExampleTestSuite ()
1317 r := Runtime {}
14- got := r .Start (s , SingleConcurrent )
18+ got := r .Start (s )
1519
1620 assert .IsType (t , make (<- chan TestResult ), got )
1721
@@ -30,7 +34,7 @@ func TestRuntime_WithRetries(t *testing.T) {
3034 s [0 ].Command .Cmd = "echo fail"
3135
3236 r := Runtime {}
33- got := r .Start (s , 1 )
37+ got := r .Start (s )
3438
3539 var counter = 0
3640 for r := range got {
@@ -50,7 +54,7 @@ func TestRuntime_WithRetriesAndInterval(t *testing.T) {
5054
5155 start := time .Now ()
5256 r := Runtime {}
53- got := r .Start (s , 0 )
57+ got := r .Start (s )
5458
5559 var counter = 0
5660 for r := range got {
@@ -64,6 +68,26 @@ func TestRuntime_WithRetriesAndInterval(t *testing.T) {
6468 assert .True (t , duration .Seconds () > 0.15 , "Retry interval did not work" )
6569}
6670
71+ func Test_Runtime_getExecutor (t * testing.T ) {
72+ r := NewRuntime (
73+ Node {Name : "ssh-host" , Type : "ssh" },
74+ Node {Name : "localhost" , Type : "local" },
75+ Node {Name : "default" , Type : "" },
76+ )
77+
78+ // If empty string set as type use local executor
79+ n := r .getExecutor ("default" )
80+ assert .IsType (t , LocalExecutor {}, n )
81+
82+ n = nil
83+ n = r .getExecutor ("localhost" )
84+ assert .IsType (t , LocalExecutor {}, n )
85+
86+ n = nil
87+ n = r .getExecutor ("ssh-host" )
88+ assert .IsType (t , SSHExecutor {}, n )
89+ }
90+
6791func getExampleTestSuite () []TestCase {
6892 tests := []TestCase {
6993 {
0 commit comments