github.com/kyma-incubator/compass/components/director@v0.0.0-20230623144113-d764f56ff805/internal/info/handler_test.go (about) 1 package info_test 2 3 import ( 4 "context" 5 "net/http" 6 "net/http/httptest" 7 "testing" 8 9 "github.com/kyma-incubator/compass/components/director/pkg/certloader" 10 11 "github.com/kyma-incubator/compass/components/director/internal/info" 12 13 "github.com/stretchr/testify/require" 14 ) 15 16 func TestNewInfoHandler(t *testing.T) { 17 t.Run("should return 500 when cert cache is empty", func(t *testing.T) { 18 // GIVEN 19 ctx := context.Background() 20 certCache := certloader.NewCertificateCache() 21 22 req, err := http.NewRequest("GET", "/v1/info", nil) 23 require.NoError(t, err) 24 rr := httptest.NewRecorder() 25 handler := http.HandlerFunc(info.NewInfoHandler(ctx, info.Config{}, certCache)) 26 27 // WHEN 28 handler.ServeHTTP(rr, req) 29 // THEN 30 require.Equal(t, http.StatusInternalServerError, rr.Code) 31 }) 32 }