Jon Perritt | 59c68fc | 2014-10-06 17:32:15 -0500 | [diff] [blame] | 1 | package gophercloud |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
Jamie Hannaford | b7a764d | 2014-10-27 14:40:55 +0100 | [diff] [blame] | 5 | "time" |
Jon Perritt | 59c68fc | 2014-10-06 17:32:15 -0500 | [diff] [blame] | 6 | |
| 7 | th "github.com/rackspace/gophercloud/testhelper" |
| 8 | ) |
| 9 | |
| 10 | func TestWaitFor(t *testing.T) { |
| 11 | err := WaitFor(0, func() (bool, error) { |
Jamie Hannaford | b7a764d | 2014-10-27 14:40:55 +0100 | [diff] [blame] | 12 | time.Sleep(1 * time.Second) |
Jon Perritt | 59c68fc | 2014-10-06 17:32:15 -0500 | [diff] [blame] | 13 | return true, nil |
| 14 | }) |
| 15 | if err == nil { |
| 16 | t.Errorf("Expected error: 'Time out in WaitFor'") |
| 17 | } |
| 18 | |
| 19 | err = WaitFor(5, func() (bool, error) { |
| 20 | return true, nil |
| 21 | }) |
| 22 | th.CheckNoErr(t, err) |
| 23 | } |