Skip to content

Commit 6e4c563

Browse files
author
mirkobrombin
committed
fix: unit tests
1 parent 114dd5d commit 6e4c563

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

internal/plugin/plugin_test.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,28 @@ import (
55
"net/http/httptest"
66
"testing"
77

8+
log "github.com/sirupsen/logrus"
9+
10+
"github.com/mirkobrombin/goup/internal/config"
811
"github.com/mirkobrombin/goup/internal/server/middleware"
912
"github.com/mirkobrombin/goup/plugins"
1013
)
1114

1215
func TestPluginManager(t *testing.T) {
1316
pluginManager := GetPluginManagerInstance()
14-
1517
pluginManager.Register(&plugins.CustomHeaderPlugin{})
16-
1718
mwManager := middleware.NewMiddlewareManager()
18-
err := pluginManager.InitPlugins(mwManager)
19+
20+
conf := config.SiteConfig{
21+
CustomHeaders: map[string]string{
22+
"X-GoUP-Header": "GoUP",
23+
},
24+
}
25+
26+
logger := log.New()
27+
err := pluginManager.InitPluginsForSite(mwManager, logger, conf)
1928
if err != nil {
20-
t.Fatalf("Failed to initialize plugin: %v", err)
29+
t.Fatalf("Failed to initialize plugin for site: %v", err)
2130
}
2231

2332
handler := mwManager.Apply(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

internal/server/middleware/middleware_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func TestTimeoutMiddleware(t *testing.T) {
5959
t.Errorf("Expected status code %d, got %d", http.StatusServiceUnavailable, w.Code)
6060
}
6161

62-
expectedBody := "Request timed out\n"
62+
expectedBody := "Request timed out"
6363
if w.Body.String() != expectedBody {
6464
t.Errorf("Expected body %q, got %q", expectedBody, w.Body.String())
6565
}

0 commit comments

Comments
 (0)