Skip to content

Commit 457cb23

Browse files
committed
improve test
1 parent 984d9fe commit 457cb23

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

services/webhook/feishu_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ func TestFeishuJSONPayload(t *testing.T) {
168168
URL: "https://feishu.example.com/",
169169
Meta: `{}`,
170170
HTTPMethod: "POST",
171+
Secret: "secret",
171172
}
172173
task := &webhook_model.HookTask{
173174
HookID: hook.ID,
@@ -188,8 +189,8 @@ func TestFeishuJSONPayload(t *testing.T) {
188189
err = json.NewDecoder(req.Body).Decode(&body)
189190
assert.NoError(t, err)
190191
assert.Equal(t, "[test/repo:test] \r\n[2020558](http://localhost:3000/test/repo/commit/2020558fe2e34debb818a514715839cabd25e778) commit message - user1\r\n[2020558](http://localhost:3000/test/repo/commit/2020558fe2e34debb818a514715839cabd25e778) commit message - user1", body.Content.Text)
191-
}
192+
assert.Equal(t, feishuGenSign(hook.Secret, body.Timestamp), body.Sign)
192193

193-
func TestFeishuGenSign(t *testing.T) {
194+
// a separate sign test, the result is generated by official python code, so the algo must be correct
194195
assert.Equal(t, "rWZ84lcag1x9aBFhn1gtV4ZN+4gme3pilfQNMk86vKg=", feishuGenSign("a", 1))
195196
}

0 commit comments

Comments
 (0)