Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Golang package #348

Merged
merged 23 commits into from
Apr 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion validate_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
package agents

import (
"fmt"
"testing"

"github.com/stretchr/testify/require"
)

func TestPatterns(t *testing.T) {
for i, crawler := range Crawlers {
// loading all crawlers wwith go:embed
// some validation happens in UnmarshalJSON
allCrawlers := Crawlers

// there is at least 10 crawlers
require.GreaterOrEqual(t, len(allCrawlers), 10)

for i, crawler := range allCrawlers {
t.Run(crawler.URL, func(t *testing.T) {
// print pattern to console for quickcheck in CI
fmt.Print(crawler.Pattern)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use fmt.Println to print each pattern on a separate line.

Also maybe it is better to put crawler.Pattern as subtest name (first argument of t.Run) and run with go test -v, it will print each subtest name (which would be a pattern).

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great idea, could you do it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I pushed to the branch.


for _, instance := range crawler.Instances {
require.True(t, IsCrawler(instance), instance)
require.Contains(t, MatchingCrawlers(instance), i, instance)
Expand Down