github.com/grafviktor/keep-my-secret@v0.9.10-0.20230908165355-19f35cce90e5/internal/api/web/middleware/middleware_test.go (about)

     1  package middleware
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/require"
     7  
     8  	"github.com/grafviktor/keep-my-secret/internal/config"
     9  )
    10  
    11  func TestNewMiddleware(t *testing.T) {
    12  	// Create a sample AppConfig for testing
    13  	appConfig := config.AppConfig{}
    14  
    15  	// Call the New function to create a middleware instance
    16  	mw := New(appConfig)
    17  
    18  	// Check if the config field of the middleware matches the expected AppConfig
    19  	if mw.config != appConfig {
    20  		t.Errorf("Expected middleware config to be %+v, but got %+v", appConfig, mw.config)
    21  	}
    22  
    23  	// Check if the config field of the middleware matches the expected AppConfig
    24  	require.NotNil(t, mw.authVerifier)
    25  }