MCPcopy Index your code
hub / github.com/bytebase/bytebase / TestPostMessage

Function TestPostMessage

backend/plugin/webhook/googlechat/googlechat_test.go:148–167  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

146}
147
148func TestPostMessage(t *testing.T) {
149 a := require.New(t)
150 var received MessagePayload
151 server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
152 a.Equal(http.MethodPost, r.Method)
153 a.Equal("application/json; charset=UTF-8", r.Header.Get("Content-Type"))
154 a.NoError(json.NewDecoder(r.Body).Decode(&received))
155 w.WriteHeader(http.StatusOK)
156 _, _ = w.Write([]byte(`{"name":"spaces/AAAA/messages/1"}`))
157 }))
158 defer server.Close()
159
160 err := postMessage(webhook.Context{
161 URL: server.URL,
162 Title: "Issue created",
163 })
164
165 a.NoError(err)
166 a.Empty(received.Text)
167}
168
169func TestPostMessageNon2xx(t *testing.T) {
170 a := require.New(t)

Callers

nothing calls this directly

Calls 6

GetMethod · 0.80
DecodeMethod · 0.80
NewDecoderMethod · 0.80
postMessageFunction · 0.70
EqualMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected