go test -timeout examples

This commit is contained in:
Mihalis Tsoukalos 2019-04-18 11:41:07 +03:00
commit 737976ded7
2 changed files with 33 additions and 2 deletions

View file

@ -1,7 +1,6 @@
package main
import (
"fmt"
"time"
)
@ -9,6 +8,14 @@ func sleep_with_me() {
time.Sleep(5 * time.Second)
}
func get_one() int {
return 1
}
func get_two() int {
return 2
}
func main() {
}

View file

@ -1,5 +1,29 @@
package main
import (
"fmt"
"testing"
)
func Test_test_one(t *testing.T) {
sleep_with_me()
value := get_one()
if value != 1 {
t.Errorf("Function returned %v", value)
}
sleep_with_me()
}
func Test_test_two(t *testing.T) {
sleep_with_me()
value := get_two()
if value != 2 {
t.Errorf("Function returned %v", value)
}
}
func Test_that_will_fail(t *testing.T) {
value := get_one()
if value != 2 {
t.Errorf("Function returned %v", value)
}
}