working commit

This commit is contained in:
2026-01-23 19:26:56 +02:00
parent 772657d9be
commit d704a76bee
10 changed files with 161 additions and 76 deletions
+37 -2
View File
@@ -14,7 +14,7 @@ import (
"github.com/stretchr/testify/require"
)
func TestServiceHello(t *testing.T) {
func TestFileExists(t *testing.T) {
var err error
srv, err := server.NewServer()
require.NoError(t, err)
@@ -25,7 +25,42 @@ func TestServiceHello(t *testing.T) {
err = srv.Build()
require.NoError(t, err)
reqPath := service.PathServiceHello
reqPath := "/api/v3/file/foo/bare/abc123"
routePath := `/api/v3/file/{filepath}`
rout := router.NewRouter()
hand := srv.Handler()
require.NotNil(t, hand)
rout.Head(routePath, hand.FileExists)
request, err := http.NewRequest("HEAD", reqPath, nil)
require.NoError(t, err)
recorder := httptest.NewRecorder()
rout.ServeHTTP(recorder, request)
require.Equal(t, http.StatusOK, recorder.Code)
fmt.Printf("Response code: %d\n", recorder.Code)
//bodyReader := recorder.Body
//bodyBytes, err := io.ReadAll(bodyReader)
//fmt.Printf("Response body: %s\n", string(bodyBytes))
}
func xxxTestServiceHello(t *testing.T) {
var err error
srv, err := server.NewServer()
require.NoError(t, err)
err = srv.Configure()
require.NoError(t, err)
err = srv.Build()
require.NoError(t, err)
reqPath := service.ServiceHelloPath
rout := router.NewRouter()
hand := srv.Handler()