Use _test package

This commit is contained in:
Till Faelligen 2022-12-01 13:25:33 +01:00
parent d8d0bb4cfc
commit 3a23f48c76
No known key found for this signature in database
GPG key ID: ACCDC9606D472758

View file

@ -1,4 +1,4 @@
package appservice package appservice_test
import ( import (
"context" "context"
@ -12,6 +12,7 @@ import (
"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/matrix-org/dendrite/appservice"
"github.com/matrix-org/dendrite/appservice/api" "github.com/matrix-org/dendrite/appservice/api"
"github.com/matrix-org/dendrite/appservice/inthttp" "github.com/matrix-org/dendrite/appservice/inthttp"
"github.com/matrix-org/dendrite/internal/httputil" "github.com/matrix-org/dendrite/internal/httputil"
@ -76,7 +77,7 @@ func TestAppserviceInternalAPI(t *testing.T) {
} }
})) }))
// only one DBType, since userapi.AddInternalRoutes complains about multiple prometheus counters added // only one DBType, since appservice.AddInternalRoutes complains about multiple prometheus counters added
base, closeBase := testrig.CreateBaseDendrite(t, test.DBTypeSQLite) base, closeBase := testrig.CreateBaseDendrite(t, test.DBTypeSQLite)
defer closeBase() defer closeBase()
@ -99,7 +100,7 @@ func TestAppserviceInternalAPI(t *testing.T) {
// Create required internal APIs // Create required internal APIs
rsAPI := roomserver.NewInternalAPI(base) rsAPI := roomserver.NewInternalAPI(base)
usrAPI := userapi.NewInternalAPI(base, &base.Cfg.UserAPI, nil, nil, rsAPI, nil) usrAPI := userapi.NewInternalAPI(base, &base.Cfg.UserAPI, nil, nil, rsAPI, nil)
asAPI := NewInternalAPI(base, usrAPI, rsAPI) asAPI := appservice.NewInternalAPI(base, usrAPI, rsAPI)
// The test cases to run // The test cases to run
runCases := func(t *testing.T, testAPI api.AppServiceInternalAPI) { runCases := func(t *testing.T, testAPI api.AppServiceInternalAPI) {
@ -134,7 +135,7 @@ func TestAppserviceInternalAPI(t *testing.T) {
// Finally execute the tests // Finally execute the tests
t.Run("HTTP API", func(t *testing.T) { t.Run("HTTP API", func(t *testing.T) {
router := mux.NewRouter().PathPrefix(httputil.InternalPathPrefix).Subrouter() router := mux.NewRouter().PathPrefix(httputil.InternalPathPrefix).Subrouter()
AddInternalRoutes(router, asAPI) appservice.AddInternalRoutes(router, asAPI)
apiURL, cancel := test.ListenAndServe(t, router, false) apiURL, cancel := test.ListenAndServe(t, router, false)
defer cancel() defer cancel()