You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bog/server/bog_test.go

58 lines
1.2 KiB
Go

package server
import (
"testing"
// "fmt"
"caj-larsson/bog/dataswamp"
"caj-larsson/bog/dataswamp/namespace"
ns "caj-larsson/bog/infrastructure/memory/namespace"
"caj-larsson/bog/infrastructure/memory/swampfile"
"caj-larsson/bog/infrastructure/system_time"
"github.com/matryer/is"
"net/http"
"net/http/httptest"
"strings"
"time"
)
3 years ago
type TestLogger struct{}
func (t TestLogger) Debug(format string, a ...interface{}) {}
func (t TestLogger) Info(format string, a ...interface{}) {}
func (t TestLogger) Warn(format string, a ...interface{}) {}
func TestApplication(t *testing.T) {
is := is.New(t)
3 years ago
logger := TestLogger{}
nsRepo := ns.NewRepository()
ns_svc := namespace.NewNamespaceService(
nsRepo,
logger,
system_time.Clock{},
time.Hour,
1000,
)
file_service := dataswamp.NewSwampFileService(
*ns_svc,
swampfile.NewRepository(),
3 years ago
logger,
)
bog := Bog{
router: new(http.ServeMux),
file_service: *file_service,
address: "fake",
3 years ago
logger: logger,
}
bog.routes()
req := httptest.NewRequest("POST", "/apath", strings.NewReader("testdata"))
req.Header.Add("User-Agent", "testingclient")
req.Header.Add("Content-Length", "8")
w := httptest.NewRecorder()
bog.router.ServeHTTP(w, req)
is.Equal(w.Code, 200)
}