(t *testing.T)
| 43 | } |
| 44 | |
| 45 | func TestHandler_GoRunHttpServer(t *testing.T) { |
| 46 | h := newHandler() |
| 47 | defer h.Close() |
| 48 | |
| 49 | handlerFunc := func(c *gin.Context) { |
| 50 | c.String(http.StatusOK, "hello world!") |
| 51 | } |
| 52 | |
| 53 | h.GoRunHTTPServer([]RouterInfo{ |
| 54 | { |
| 55 | FuncName: "create", |
| 56 | Method: http.MethodPost, |
| 57 | Path: "/user", |
| 58 | HandlerFunc: handlerFunc, |
| 59 | }, |
| 60 | { |
| 61 | FuncName: "deleteByID", |
| 62 | Method: http.MethodDelete, |
| 63 | Path: "/user/:id", |
| 64 | HandlerFunc: handlerFunc, |
| 65 | }, |
| 66 | { |
| 67 | FuncName: "updateByID", |
| 68 | Method: http.MethodPut, |
| 69 | Path: "/user/:id", |
| 70 | HandlerFunc: handlerFunc, |
| 71 | }, |
| 72 | { |
| 73 | FuncName: "updateByID2", |
| 74 | Method: http.MethodPatch, |
| 75 | Path: "/user2/:id", |
| 76 | HandlerFunc: handlerFunc, |
| 77 | }, |
| 78 | { |
| 79 | FuncName: "getById", |
| 80 | Method: http.MethodGet, |
| 81 | Path: "/user/:id", |
| 82 | HandlerFunc: handlerFunc, |
| 83 | }, |
| 84 | { |
| 85 | FuncName: "options", |
| 86 | Method: http.MethodOptions, |
| 87 | Path: "/user", |
| 88 | HandlerFunc: handlerFunc, |
| 89 | }, |
| 90 | }) |
| 91 | |
| 92 | time.Sleep(time.Millisecond * 200) |
| 93 | url := h.GetRequestURL("updateByID", 1) |
| 94 | t.Log(url) |
| 95 | |
| 96 | time.Sleep(time.Millisecond * 100) |
| 97 | ctx, _ := context.WithTimeout(context.Background(), time.Second) |
| 98 | _ = h.HTTPServer.Shutdown(ctx) |
| 99 | } |
nothing calls this directly
no test coverage detected