MCPcopy Index your code
hub / github.com/dnote/dnote / TestNotSupportedVersions

Function TestNotSupportedVersions

pkg/server/controllers/routes_test.go:28–72  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

26)
27
28func TestNotSupportedVersions(t *testing.T) {
29 testCases := []struct {
30 path string
31 }{
32 // v1
33 {
34 path: "/api/v1",
35 },
36 {
37 path: "/api/v1/foo",
38 },
39 {
40 path: "/api/v1/bar/baz",
41 },
42 // v2
43 {
44 path: "/api/v2",
45 },
46 {
47 path: "/api/v2/foo",
48 },
49 {
50 path: "/api/v2/bar/baz",
51 },
52 }
53
54 // setup
55 db := testutils.InitMemoryDB(t)
56 a := app.NewTest()
57 a.Clock = clock.NewMock()
58 a.DB = db
59 server := MustNewServer(t, &a)
60 defer server.Close()
61
62 for _, tc := range testCases {
63 t.Run(tc.path, func(t *testing.T) {
64 // execute
65 req := testutils.MakeReq(server.URL, "GET", tc.path, "")
66 res := testutils.HTTPDo(t, req)
67
68 // test
69 assert.Equal(t, res.StatusCode, http.StatusGone, "status code mismatch")
70 })
71 }
72}

Callers

nothing calls this directly

Calls 8

InitMemoryDBFunction · 0.92
NewTestFunction · 0.92
NewMockFunction · 0.92
MakeReqFunction · 0.92
HTTPDoFunction · 0.92
EqualFunction · 0.92
MustNewServerFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected