Skip to content

Commit

Permalink
Tracking scripts: Add missing test case (#237)
Browse files Browse the repository at this point in the history
* Trackingscripts: Check for urls

* Do not stop after finding the first

* Add missing test case

* Add tracking test
  • Loading branch information
academo authored Jul 22, 2024
1 parent f03c5c1 commit 3bfde5a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pkg/analysis/passes/trackingscripts/trackingscripts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,21 @@ func TestTrackingScriptsInvalid(t *testing.T) {
"Tracking scripts are not allowed in Grafana plugins (e.g. google analytics). Please remove any usage of tracking code. Found: https://www.google-analytics.com/analytics.js",
)
}

func TestNoFalsePositiveForSringsLookingLikeDomains(t *testing.T) {
var interceptor testpassinterceptor.TestPassInterceptor
var moduleJsMap = map[string][]byte{
"module.js": []byte(`grafana-asserts-app.rules:read`),
}
pass := &analysis.Pass{
RootDir: filepath.Join("./"),
ResultOf: map[*analysis.Analyzer]interface{}{
modulejs.Analyzer: moduleJsMap,
},
Report: interceptor.ReportInterceptor(),
}

_, err := Analyzer.Run(pass)
require.NoError(t, err)
require.Len(t, interceptor.Diagnostics, 0)
}

0 comments on commit 3bfde5a

Please sign in to comment.