Skip to content

Trying to provide iris support for oapi-codegen #2132

Closed Answered by kataras
Ns2Kracy asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @Ns2Kracy,

func TestOapiRequestValidator(t *testing.T) {
	i := iris.New()

	called := false

	// Install a request handler for /resource. We want to make sure it doesn't
	// get called.
	i.Get("/resource", func(c iris.Context) {
		called = true
	})
	
	// HERE: call i.Build() before tests.
	if err := i.Build(); err != nil {
	     t.Fatal(err)
	}
	// Let's send the request to the wrong server, this should fail validation
	{
		rec := doGet(t, i, "http://not.deepmap.ai/resource")
		assert.Equal(t, http.StatusBadRequest, rec.Code)
		assert.False(t, called, "Handler should not have been called")
	}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Ns2Kracy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants