Skip to content

Commit

Permalink
mgmt-framework: Server UT Return valid status code for go1.19/src/net…
Browse files Browse the repository at this point in the history
…/http/httptest/recorder.go-checkWriteHeaderCode()
  • Loading branch information
amrutasali committed Apr 19, 2024
1 parent 322ed43 commit 5e26ae0
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions rest/server/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,22 @@ var testRouter *Router

// Basic mux.Router tests
func TestRoutes(t *testing.T) {
AddRoute("one", "GET", "/testroute/1", newHandler(1))
AddRoute("two", "GET", "/testroute/2", newHandler(2))
AddRoute("two", "GET", "/restconf/data/testroute/3", newHandler(3))
AddRoute("two", "GET", "/restconf/data/testroute/4", newHandler(4))
// The code has to be valid, otherwise latest (1.19) version of go package
// panics. (Panic info for URL /testroute/1: invalid WriteHeader code 1)
// go1.19/src/net/http/httptest/recorder.go:148
AddRoute("one", "GET", "/testroute/1", newHandler(200))
AddRoute("two", "GET", "/testroute/2", newHandler(202))
AddRoute("two", "GET", "/restconf/data/testroute/3", newHandler(203))
AddRoute("two", "GET", "/restconf/data/testroute/4", newHandler(204))

testRouter = newDefaultRouter()

// Try the test URLs and an unknown URL. The unknonw path
// should return 404
t.Run("Get1", testGet("/testroute/1", 1))
t.Run("Get2", testGet("/testroute/2", 2))
t.Run("Get3", testGet("/restconf/data/testroute/3", 3))
t.Run("Get4", testGet("/restconf/data/testroute/4", 4))
t.Run("Get1", testGet("/testroute/1", 200))
t.Run("Get2", testGet("/testroute/2", 202))
t.Run("Get3", testGet("/restconf/data/testroute/3", 203))
t.Run("Get4", testGet("/restconf/data/testroute/4", 204))
t.Run("GetUnknown", testGet("/testroute/4", 404))
t.Run("Meta", testGet("/.well-known/host-meta", 200))

Expand Down

0 comments on commit 5e26ae0

Please sign in to comment.