github.com/prebid/prebid-server/v2@v2.18.0/endpoints/status_test.go (about)

     1  package endpoints
     2  
     3  import (
     4  	"net/http"
     5  	"net/http/httptest"
     6  	"testing"
     7  )
     8  
     9  func TestStatusNoContent(t *testing.T) {
    10  	handler := NewStatusEndpoint("")
    11  	w := httptest.NewRecorder()
    12  	handler(w, nil, nil)
    13  	if w.Code != http.StatusNoContent {
    14  		t.Errorf("Bad code for empty content. Expected %d, got %d", http.StatusNoContent, w.Code)
    15  	}
    16  }
    17  
    18  func TestStatusWithContent(t *testing.T) {
    19  	handler := NewStatusEndpoint("ready")
    20  	w := httptest.NewRecorder()
    21  	handler(w, nil, nil)
    22  	if w.Code != http.StatusOK {
    23  		t.Errorf("Bad code for empty content. Expected %d, got %d", http.StatusOK, w.Code)
    24  	}
    25  	if w.Body.String() != "ready" {
    26  		t.Errorf("Bad status body. Expected %s, got %s", "ready", w.Body.String())
    27  	}
    28  }