(t *testing.T)
| 29 | ) |
| 30 | |
| 31 | func TestStartStopProfile(t *testing.T) { |
| 32 | Convey("start normally", t, func() { |
| 33 | defer os.Remove(cpuProfile) |
| 34 | defer os.Remove(memProfile) |
| 35 | err := StartProfile(cpuProfile, memProfile) |
| 36 | So(err, ShouldBeNil) |
| 37 | |
| 38 | StopProfile() |
| 39 | cpuFileInfo, err := os.Stat(cpuProfile) |
| 40 | So(cpuFileInfo.Size(), ShouldBeGreaterThan, 0) |
| 41 | So(err, ShouldBeNil) |
| 42 | |
| 43 | memFileInfo, err := os.Stat(memProfile) |
| 44 | So(memFileInfo.Size(), ShouldBeGreaterThan, 0) |
| 45 | So(err, ShouldBeNil) |
| 46 | }) |
| 47 | Convey("start empty", t, func() { |
| 48 | err := StartProfile("", "") |
| 49 | So(err, ShouldBeNil) |
| 50 | |
| 51 | StopProfile() |
| 52 | }) |
| 53 | Convey("start no such path", t, func() { |
| 54 | err := StartProfile("/not/exist/path", "") |
| 55 | So(err, ShouldNotBeNil) |
| 56 | |
| 57 | StopProfile() |
| 58 | |
| 59 | err = StartProfile("", "/not/exist/path") |
| 60 | So(err, ShouldNotBeNil) |
| 61 | |
| 62 | StopProfile() |
| 63 | }) |
| 64 | } |
nothing calls this directly
no test coverage detected