mirror of
https://github.com/Dvorinka/Devour.git
synced 2026-06-03 20:13:03 +00:00
40 lines
1.6 KiB
Go
40 lines
1.6 KiB
Go
package cmd
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/yourorg/devour/internal/scraper"
|
|
)
|
|
|
|
func TestDetectSourceType(t *testing.T) {
|
|
tests := []struct {
|
|
url string
|
|
wantType scraper.SourceType
|
|
}{
|
|
{"https://pkg.go.dev/net/http", scraper.SourceTypeGoDocs},
|
|
{"https://docs.rs/tokio/latest/tokio/", scraper.SourceTypeRustDocs},
|
|
{"https://docs.python.org/3/library/asyncio.html", scraper.SourceTypePythonDocs},
|
|
{"https://docs.oracle.com/javase/8/docs/api/java/util/List.html", scraper.SourceTypeJavaDocs},
|
|
{"https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/", scraper.SourceTypeSpringDocs},
|
|
{"https://www.typescriptlang.org/docs/handbook/2/basic-types.html", scraper.SourceTypeTSDocs},
|
|
{"https://react.dev/reference/react", scraper.SourceTypeReactDocs},
|
|
{"https://vuejs.org/guide/introduction.html", scraper.SourceTypeVueDocs},
|
|
{"https://nuxt.com/docs/guide/directory-structure", scraper.SourceTypeNuxtDocs},
|
|
{"https://docs.docker.com/compose", scraper.SourceTypeDockerDocs},
|
|
{"https://hub.docker.com/mcp/server/github", scraper.SourceTypeMCPDocs},
|
|
{"https://developers.cloudflare.com/workers", scraper.SourceTypeCloudflareDocs},
|
|
{"https://docs.astro.build/en/guides/components/", scraper.SourceTypeAstroDocs},
|
|
{"https://github.com/yourorg/devour", scraper.SourceTypeGitHub},
|
|
{"https://example.com/docs", scraper.SourceTypeWeb},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.url, func(t *testing.T) {
|
|
got := detectSourceType(tt.url)
|
|
if got != tt.wantType {
|
|
t.Fatalf("detectSourceType(%q) = %q, want %q", tt.url, got, tt.wantType)
|
|
}
|
|
})
|
|
}
|
|
}
|