github.com/goravel/framework@v1.13.9/http/context_test.go (about)

     1  package http
     2  
     3  import (
     4  	"context"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/suite"
     8  )
     9  
    10  type ContextTestSuite struct {
    11  	suite.Suite
    12  	ctx *Context
    13  }
    14  
    15  func TestContextTestSuite(t *testing.T) {
    16  	suite.Run(t, new(ContextTestSuite))
    17  }
    18  
    19  func (s *ContextTestSuite) SetupTest() {
    20  	s.ctx = NewContext()
    21  }
    22  
    23  func (s *ContextTestSuite) TestContext() {
    24  	s.Equal(context.Background(), s.ctx.Context())
    25  }
    26  
    27  func (s *ContextTestSuite) TestWithValue() {
    28  	s.ctx.WithValue("Hello", "world")
    29  	s.Equal("world", s.ctx.Value("Hello"))
    30  }
    31  
    32  func (s *ContextTestSuite) TestRequest() {
    33  	s.Nil(s.ctx.Request())
    34  }
    35  
    36  func (s *ContextTestSuite) TestResponse() {
    37  	s.Nil(s.ctx.Response())
    38  }