Add documentation identifier consistency tests
This commit is contained in:
32
internal/sources/docs_test.go
Normal file
32
internal/sources/docs_test.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package sources
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDocumentedRegisteredSourceDrivers(t *testing.T) {
|
||||
docs := map[string]string{
|
||||
"docs/config.md": readDoc(t, "../../docs/config.md"),
|
||||
"docs/internal/sources.md": readDoc(t, "../../docs/internal/sources.md"),
|
||||
}
|
||||
|
||||
for _, reg := range pollDriverRegistrations {
|
||||
for path, doc := range docs {
|
||||
if !strings.Contains(doc, reg.driver) {
|
||||
t.Fatalf("%s missing source driver %q", path, reg.driver)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func readDoc(t *testing.T, path string) string {
|
||||
t.Helper()
|
||||
|
||||
raw, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
t.Fatalf("ReadFile(%s) error = %v", path, err)
|
||||
}
|
||||
return string(raw)
|
||||
}
|
||||
Reference in New Issue
Block a user