Add projects
This commit is contained in:
parent
2d3a9ad623
commit
8b607dd700
1802 changed files with 503346 additions and 2 deletions
|
|
@ -0,0 +1,50 @@
|
|||
package interactions_test
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestInteractionsTranslatorsDoNotImportGeminiTranslators(t *testing.T) {
|
||||
repoRoot := filepath.Clean(filepath.Join("..", "..", ".."))
|
||||
scanDirs := []string{
|
||||
"internal/translator/openai/interactions",
|
||||
"internal/translator/claude/interactions",
|
||||
"internal/translator/codex/interactions",
|
||||
"internal/translator/antigravity/interactions",
|
||||
}
|
||||
forbidden := regexp.MustCompile(`"github\.com/router-for-me/CLIProxyAPI/v7/internal/translator/[^"]*/gemini[^"]*"`)
|
||||
var violations []string
|
||||
for _, scanDir := range scanDirs {
|
||||
root := filepath.Join(repoRoot, scanDir)
|
||||
errWalk := filepath.WalkDir(root, func(path string, entry os.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if entry.IsDir() || !strings.HasSuffix(path, ".go") {
|
||||
return nil
|
||||
}
|
||||
data, errRead := os.ReadFile(path)
|
||||
if errRead != nil {
|
||||
return errRead
|
||||
}
|
||||
if forbidden.Match(data) {
|
||||
rel, errRel := filepath.Rel(repoRoot, path)
|
||||
if errRel != nil {
|
||||
rel = path
|
||||
}
|
||||
violations = append(violations, rel)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if errWalk != nil {
|
||||
t.Fatalf("scan %s: %v", scanDir, errWalk)
|
||||
}
|
||||
}
|
||||
if len(violations) > 0 {
|
||||
t.Fatalf("non-Gemini Interactions translators import Gemini translators: %s", strings.Join(violations, ", "))
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue