Add initial Go server skeleton with HTTP handlers, middleware, job runner, and stubs
This commit is contained in:
25
internal/http/handlers_test.go
Normal file
25
internal/http/handlers_test.go
Normal file
@@ -0,0 +1,25 @@
|
||||
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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user