|
| 1 | +package webhook |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + "github.com/stretchr/testify/assert" |
| 7 | +) |
| 8 | + |
| 9 | +func TestBugCommentEvent_BugCommentAddEvent(t *testing.T) { |
| 10 | + var event BugCommentAddEvent |
| 11 | + loadAndParseWebhookData(t, "bug_comment/add.json", &event) |
| 12 | + |
| 13 | + assert.Equal(t, event, BugCommentAddEvent{ |
| 14 | + Event: EventTypeBugCommentAdd, |
| 15 | + EventFrom: "web", |
| 16 | + Referer: "https://www.tapd.cn/tapd_fe/111222/bug/list?confId=11111222001048467&dialog_preview_id=bug_11111222001037212", |
| 17 | + WorkspaceID: "111222", |
| 18 | + CurrentUser: "张三", |
| 19 | + ID: "11111222001036001", |
| 20 | + Title: "在状态 [新] 添加", |
| 21 | + Description: "<p>123123</p>", |
| 22 | + Author: "张三", |
| 23 | + EntityID: "11111222001037212", |
| 24 | + Secret: "", |
| 25 | + RioToken: "", |
| 26 | + DevProxyHost: "http://websocket-proxy", |
| 27 | + QueueID: "318928285", |
| 28 | + EventID: "183722797", |
| 29 | + Created: "2024-12-30 17:41:02", |
| 30 | + }) |
| 31 | +} |
| 32 | + |
| 33 | +func TestBugCommentEvent_BugCommentUpdateEvent(t *testing.T) { |
| 34 | + var event BugCommentUpdateEvent |
| 35 | + loadAndParseWebhookData(t, "bug_comment/update.json", &event) |
| 36 | + |
| 37 | + assert.Equal(t, event, BugCommentUpdateEvent{ |
| 38 | + Event: EventTypeBugCommentUpdate, |
| 39 | + EventFrom: "web", |
| 40 | + Referer: "https://www.tapd.cn/tapd_fe/111222333/bug/list?confId=11111222333001048467&dialog_preview_id=bug_11111222333001037212", |
| 41 | + WorkspaceID: "111222333", |
| 42 | + CurrentUser: "张三", |
| 43 | + ID: "11111222333001036001", |
| 44 | + Description: "<p>12312323</p>", |
| 45 | + Author: "张三", |
| 46 | + EntityID: "11111222333001037212", |
| 47 | + Secret: "", |
| 48 | + RioToken: "", |
| 49 | + DevProxyHost: "http://websocket-proxy", |
| 50 | + QueueID: "318963935", |
| 51 | + EventID: "183737413", |
| 52 | + Created: "2024-12-30 18:30:02", |
| 53 | + }) |
| 54 | +} |
| 55 | + |
| 56 | +func TestBugCommentEvent_BugCommentDeleteEvent(t *testing.T) { |
| 57 | + var event BugCommentDeleteEvent |
| 58 | + loadAndParseWebhookData(t, "bug_comment/delete.json", &event) |
| 59 | + |
| 60 | + assert.Equal(t, event, BugCommentDeleteEvent{ |
| 61 | + Event: EventTypeBugCommentDelete, |
| 62 | + EventFrom: "web", |
| 63 | + Referer: "https://www.tapd.cn/111111/comments/delete_comment/", |
| 64 | + WorkspaceID: "111111", |
| 65 | + CurrentUser: "李四", |
| 66 | + ID: "11111111001035977", |
| 67 | + Description: "<p>這個可能是需求</p>", |
| 68 | + Author: "李四", |
| 69 | + EntityID: "11111111001039882", |
| 70 | + Secret: "", |
| 71 | + RioToken: "", |
| 72 | + DevProxyHost: "http://websocket-proxy", |
| 73 | + QueueID: "318938077", |
| 74 | + EventID: "183726824", |
| 75 | + Created: "2024-12-30 17:55:19", |
| 76 | + }) |
| 77 | +} |
0 commit comments