fix(oo): skip junk dirs in applications Discover

Stop inventing CRM companies from node_modules/tools README trees.
Only sync dossier-like folders (source-NNN-…) and invent Company from
the slug token after the numeric id.
This commit is contained in:
2026-07-23 14:43:45 +01:00
parent 38932b0e0e
commit 830f0c7208
3 changed files with 85 additions and 4 deletions
+43
View File
@@ -1,6 +1,8 @@
package applications
import (
"os"
"path/filepath"
"testing"
onlyoffice "github.com/eslider/go-onlyoffice"
@@ -15,6 +17,47 @@ func TestDealTitleForApplication(t *testing.T) {
}
}
func TestLooksLikeAppFolder(t *testing.T) {
cases := map[string]bool{
"uae-009-dizzaract-senior-backend-devops-abu-dhabi": true,
"djinni-001-devops-engineer-windows-cloud-justmarkets": true,
"linkedin-elastic-senior-go-intake-observability": true, // no NNN but long
"alex-staff-cloud-platform-engineer": true,
"http-client": false,
"node_modules": false,
"tools": false,
"README": false,
"uae-009": false, // too short
}
for name, want := range cases {
if got := looksLikeAppFolder(name); got != want {
t.Errorf("looksLikeAppFolder(%q)=%v want %v", name, got, want)
}
}
}
func TestDiscoverSkipsNodeModules(t *testing.T) {
root := t.TempDir()
appDir := filepath.Join(root, "uae-009-dizzaract-senior-backend-devops-abu-dhabi")
junk := filepath.Join(root, "node_modules", "http-client")
tools := filepath.Join(root, "tools", "gmail-oo-reconcile")
for _, d := range []string{appDir, junk, tools} {
if err := os.MkdirAll(d, 0o755); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(filepath.Join(d, "README.md"), []byte("# x\n"), 0o644); err != nil {
t.Fatal(err)
}
}
got, err := Discover(root)
if err != nil {
t.Fatal(err)
}
if len(got) != 1 || filepath.Base(filepath.Dir(got[0])) != filepath.Base(appDir) {
t.Fatalf("Discover=%v want only %s", got, appDir)
}
}
func TestHasContactInfoHelper(t *testing.T) {
contact := map[string]any{
"commonData": []any{