From 28077cde3049b44cf5003fc2e3134cb99f1394fe Mon Sep 17 00:00:00 2001 From: Till Faelligen <2353100+S7evinK@users.noreply.github.com> Date: Fri, 2 Dec 2022 15:16:24 +0100 Subject: [PATCH] Add TODO, add comment/make more obvious what's happening --- appservice/appservice_test.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/appservice/appservice_test.go b/appservice/appservice_test.go index 08853c10f..5a3a9aef7 100644 --- a/appservice/appservice_test.go +++ b/appservice/appservice_test.go @@ -39,8 +39,8 @@ func TestAppserviceInternalAPI(t *testing.T) { srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { switch { case strings.Contains(r.URL.Path, "location"): - - if r.URL.Path[len(r.URL.Path)-3:] == existingProtocol { + // Check if we've got an existing protocol, if so, return a proper response. + if r.URL.Path[len(r.URL.Path)-len(existingProtocol):] == existingProtocol { if err := json.NewEncoder(w).Encode(wantLocationResponse); err != nil { t.Fatalf("failed to encode response: %s", err) } @@ -51,7 +51,7 @@ func TestAppserviceInternalAPI(t *testing.T) { } return case strings.Contains(r.URL.Path, "user"): - if r.URL.Path[len(r.URL.Path)-3:] == existingProtocol { + if r.URL.Path[len(r.URL.Path)-len(existingProtocol):] == existingProtocol { if err := json.NewEncoder(w).Encode(wantUserResponse); err != nil { t.Fatalf("failed to encode response: %s", err) } @@ -62,7 +62,7 @@ func TestAppserviceInternalAPI(t *testing.T) { } return case strings.Contains(r.URL.Path, "protocol"): - if r.URL.Path[len(r.URL.Path)-3:] == existingProtocol { + if r.URL.Path[len(r.URL.Path)-len(existingProtocol):] == existingProtocol { if err := json.NewEncoder(w).Encode(wantProtocolResponse); err != nil { t.Fatalf("failed to encode response: %s", err) } @@ -77,6 +77,7 @@ func TestAppserviceInternalAPI(t *testing.T) { } })) + // TODO: use test.WithAllDatabases // only one DBType, since appservice.AddInternalRoutes complains about multiple prometheus counters added base, closeBase := testrig.CreateBaseDendrite(t, test.DBTypeSQLite) defer closeBase()