Files
storage-appliance/internal/http/handlers_test.go

26 lines
534 B
Go

package http
import (
"database/sql"
"net/http"
"net/http/httptest"
"testing"
"github.com/example/storage-appliance/internal/service/mock"
)
func TestPoolsHandler(t *testing.T) {
m := &mock.MockZFSService{}
app := &App{DB: &sql.DB{}, ZFSSvc: m}
req := httptest.NewRequest(http.MethodGet, "/api/pools", nil)
w := httptest.NewRecorder()
app.PoolsHandler(w, req)
if w.Code != http.StatusOK {
t.Fatalf("expected 200, got %d", w.Code)
}
body := w.Body.String()
if body == "" {
t.Fatalf("expected non-empty body")
}
}