(t *testing.T)
| 171 | } |
| 172 | |
| 173 | func TestPusher(t *testing.T) { |
| 174 | html := template.Must(template.New("https").Parse(` |
| 175 | <html> |
| 176 | <head> |
| 177 | <title>Https Test</title> |
| 178 | <script src="/assets/app.js"></script> |
| 179 | </head> |
| 180 | <body> |
| 181 | <h1 style="color:red;">Welcome, Ginner!</h1> |
| 182 | </body> |
| 183 | </html> |
| 184 | `)) |
| 185 | |
| 186 | router := New() |
| 187 | router.Static("./assets", "./assets") |
| 188 | router.SetHTMLTemplate(html) |
| 189 | |
| 190 | go func() { |
| 191 | router.GET("/pusher", func(c *Context) { |
| 192 | if pusher := c.Writer.Pusher(); pusher != nil { |
| 193 | err := pusher.Push("/assets/app.js", nil) |
| 194 | assert.NoError(t, err) |
| 195 | } |
| 196 | c.String(http.StatusOK, "it worked") |
| 197 | }) |
| 198 | |
| 199 | assert.NoError(t, router.RunTLS(":8449", "./testdata/certificate/cert.pem", "./testdata/certificate/key.pem")) |
| 200 | }() |
| 201 | |
| 202 | // have to wait for the goroutine to start and run the server |
| 203 | // otherwise the main thread will complete |
| 204 | time.Sleep(5 * time.Millisecond) |
| 205 | |
| 206 | require.Error(t, router.RunTLS(":8449", "./testdata/certificate/cert.pem", "./testdata/certificate/key.pem")) |
| 207 | testRequest(t, "https://localhost:8449/pusher") |
| 208 | } |
| 209 | |
| 210 | func TestRunEmptyWithEnv(t *testing.T) { |
| 211 | os.Setenv("PORT", "3123") |
nothing calls this directly
no test coverage detected