...

Source file src/edge-infra.dev/pkg/lib/server/health/health_test.go

Documentation: edge-infra.dev/pkg/lib/server/health

     1  package health_test
     2  
     3  import (
     4  	"net/http"
     5  	"net/http/httptest"
     6  	"testing"
     7  
     8  	"github.com/gin-gonic/gin"
     9  	"github.com/stretchr/testify/assert"
    10  
    11  	"edge-infra.dev/pkg/lib/server/health"
    12  )
    13  
    14  // TestNewHealthRouter simply tests that we can create a router, pass it to
    15  // NewHealthRouter and get the expected result
    16  func TestNewHealthRoute(t *testing.T) {
    17  	r := gin.Default()
    18  	health.NewHealthRoute(r)
    19  
    20  	w := httptest.NewRecorder()
    21  	req, _ := http.NewRequest("GET", "/healthz", nil)
    22  	r.ServeHTTP(w, req)
    23  
    24  	assert.Equal(t, 200, w.Code)
    25  	assert.Equal(t, "\"UP\"", w.Body.String())
    26  }
    27  

View as plain text