Skip to content

Commit 211a76d

Browse files
authored
Integration test for Google Analytics (go-gitea#248)
1 parent 2886822 commit 211a76d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

integrations/google_analytics_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package integrations
2+
3+
import (
4+
"net/http"
5+
"testing"
6+
7+
"code.gitea.io/gitea/modules/setting"
8+
9+
"github.com/stretchr/testify/assert"
10+
)
11+
12+
func TestGoogleAnalytics(t *testing.T) {
13+
// test that the google analytics javascript is included in HTML
14+
prepareTestEnv(t)
15+
setting.Google.GATrackingID = "UA-012345-6"
16+
17+
req := NewRequest(t, "GET", "/")
18+
resp := MakeRequest(t, req, http.StatusOK)
19+
htmlDoc := NewHTMLParser(t, resp.Body)
20+
scripts := htmlDoc.doc.Find("script").Text()
21+
assert.Contains(t, scripts, setting.Google.GATrackingID)
22+
}

0 commit comments

Comments
 (0)