(t *testing.T)
| 88 | } |
| 89 | |
| 90 | func TestCreateTask(t *testing.T) { |
| 91 | doTest(func() { |
| 92 | resp := httpRequestCheckOk[*download.ResolveResult](http.MethodPost, "/api/v1/resolve", resolveReq) |
| 93 | |
| 94 | var wg sync.WaitGroup |
| 95 | wg.Add(1) |
| 96 | Downloader.Listener(func(event *download.Event) { |
| 97 | if event.Key == download.EventKeyFinally { |
| 98 | wg.Done() |
| 99 | } |
| 100 | }) |
| 101 | |
| 102 | taskId := httpRequestCheckOk[string](http.MethodPost, "/api/v1/tasks", &model.CreateTask{ |
| 103 | Rid: resp.ID, |
| 104 | }) |
| 105 | if taskId == "" { |
| 106 | t.Fatal("create task failed") |
| 107 | } |
| 108 | |
| 109 | wg.Wait() |
| 110 | want := test.FileMd5(test.BuildFile) |
| 111 | got := test.FileMd5(test.DownloadFile) |
| 112 | if want != got { |
| 113 | t.Errorf("CreateTask() got = %v, want %v", got, want) |
| 114 | } |
| 115 | }) |
| 116 | } |
| 117 | |
| 118 | func TestCreateDirectTask(t *testing.T) { |
| 119 | doTest(func() { |
nothing calls this directly
no test coverage detected