go test -timeout examples
This commit is contained in:
parent
667af9f086
commit
737976ded7
2 changed files with 33 additions and 2 deletions
|
|
@ -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() {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue