(t *testing.T)
| 176 | } |
| 177 | |
| 178 | func TestLuaContextSend(t *testing.T) { |
| 179 | c := New() |
| 180 | defer c.Close() |
| 181 | c.Init(&logic.Options{DBUrl: "nosql://?secret=123"}) // nolint: errcheck |
| 182 | _, err := c.parseToken("CNjo6ua-WhIiQUJPTzZUU0lYS1NFVklKS1hMRFFTVVhRUlhVQU9YR0dZWQ..faqRNWqzTW3Fjg4xh9CS_p8IItEHjSQiYzJjxcqf_tg") |
| 183 | if err != nil { |
| 184 | t.Error(err) |
| 185 | } |
| 186 | |
| 187 | l := lua.NewState() |
| 188 | defer l.Close() |
| 189 | w := httptest.NewRecorder() |
| 190 | ctx, _ := gin.CreateTestContext(w) |
| 191 | ctx.Request, _ = http.NewRequest("POST", "/v1/webhook/github?token=CNjo6ua-WhIiQUJPTzZUU0lYS1NFVklKS1hMRFFTVVhRUlhVQU9YR0dZWQ..faqRNWqzTW3Fjg4xh9CS_p8IItEHjSQiYzJjxcqf_tg", nil) |
| 192 | ctx.Set(gin.BodyBytesKey, []byte("{}")) |
| 193 | ctx.Set(coreKey, c) |
| 194 | initHttpLua(l, ctx) |
| 195 | |
| 196 | if err := l.DoString(`ctx:send("")`); err != nil { |
| 197 | t.Fatal(err) |
| 198 | } |
| 199 | if err := l.DoString(`ctx:send("abc")`); err != nil { |
| 200 | t.Fatal(err) |
| 201 | } |
| 202 | if err := l.DoString(`ctx:send({text="123",sound=1})`); err != nil { |
| 203 | t.Fatal(err) |
| 204 | } |
| 205 | if err := l.DoString(`ctx:send({text="123",token="abc"})`); err != nil { |
| 206 | t.Fatal(err) |
| 207 | } |
| 208 | if err := l.DoString(`ctx:send({text="` + strings.Repeat("A", 4000) + `"})`); err != nil { |
| 209 | t.Fatal(err) |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | func TestLuaContextSendFailed(t *testing.T) { |
| 214 | l := lua.NewState() |
nothing calls this directly
no test coverage detected