MCPcopy
hub / github.com/GopeedLab/gopeed / TestCreateTask

Function TestCreateTask

pkg/rest/server_test.go:90–116  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

88}
89
90func 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
118func TestCreateDirectTask(t *testing.T) {
119 doTest(func() {

Callers

nothing calls this directly

Calls 5

FileMd5Function · 0.92
doTestFunction · 0.85
httpRequestCheckOkFunction · 0.85
WaitMethod · 0.65
ListenerMethod · 0.45

Tested by

no test coverage detected