Test: model.Tags / modifications

This commit is contained in:
HFO4
2020-02-12 13:19:25 +08:00
parent 15f4b1819b
commit bb63ea7142
17 changed files with 352 additions and 55 deletions

View File

@@ -50,6 +50,7 @@ func TestNewMonitor(t *testing.T) {
func TestMonitor_Loop(t *testing.T) {
asserts := assert.New(t)
notifier := make(chan StatusEvent)
MAX_RETRY = 0
monitor := &Monitor{
Task: &model.Download{GID: "gid"},
Interval: time.Duration(1) * time.Second,
@@ -72,11 +73,13 @@ func TestMonitor_Update(t *testing.T) {
// 无法获取状态
{
MAX_RETRY = 1
testInstance := new(InstanceMock)
testInstance.On("Status", testMock.Anything).Return(rpc.StatusInfo{}, errors.New("error"))
file, _ := util.CreatNestedFile("TestMonitor_Update/1")
file.Close()
Instance = testInstance
asserts.False(monitor.Update())
asserts.True(monitor.Update())
testInstance.AssertExpectations(t)
asserts.False(util.Exists("TestMonitor_Update"))