version: only git commit and build date must be modifiable

Improved some test cases too
This commit is contained in:
Nicola Murino
2019-08-08 21:42:07 +02:00
parent 90607d4f86
commit 51aacae3c5
5 changed files with 44 additions and 13 deletions

View File

@@ -1,11 +1,14 @@
package api
import (
"context"
"fmt"
"net/http"
"net/http/httptest"
"testing"
"github.com/drakkan/sftpgo/dataprovider"
"github.com/go-chi/chi"
)
const (
@@ -211,3 +214,15 @@ func TestApiCallToNotListeningServer(t *testing.T) {
}
SetBaseURL(oldBaseURL)
}
func TestCloseSFTPConnectionHandler(t *testing.T) {
req, _ := http.NewRequest(http.MethodDelete, activeConnectionsPath+"/connectionID", nil)
rctx := chi.NewRouteContext()
rctx.URLParams.Add("connectionID", "")
req = req.WithContext(context.WithValue(req.Context(), chi.RouteCtxKey, rctx))
rr := httptest.NewRecorder()
handleCloseSFTPConnection(rr, req)
if rr.Code != http.StatusBadRequest {
t.Errorf("Expected response code 400. Got %d", rr.Code)
}
}