feat(matching): rank with semantic embeddings and explain matches by evidence
This commit is contained in:
1 parent
facc1789b1
commit
24b64d698a
215 files changed
+16951
-327
No files matched your search
@@ -0,0 +1,47 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func lookupOf(values map[string]string) LookupEnv {
|
||||
return func(key string) (string, bool) {
|
||||
value, ok := values[key]
|
||||
return value, ok
|
||||
}
|
||||
}
|
||||
|
||||
func TestSemanticSettingsDefaultOffAndValidateTheMLOrigin(t *testing.T) {
|
||||
settings, err := LoadSemanticSettings(lookupOf(nil))
|
||||
if err != nil || settings.SemanticMatchingEnabled || settings.GitHubChecksEnabled ||
|
||||
settings.MLRequestTimeout != 30*time.Second || settings.RepositoryCheckInterval != 10*time.Minute {
|
||||
t.Fatalf("defaults = %+v, %v", settings, err)
|
||||
}
|
||||
enabled, err := LoadSemanticSettings(lookupOf(map[string]string{
|
||||
"SEMANTIC_MATCHING_ENABLED": "true", "ML_SERVICE_URL": "http://ml:8000", "GITHUB_TOKEN": "token-value",
|
||||
}))
|
||||
if err != nil || !enabled.SemanticMatchingEnabled || enabled.GitHubToken != "token-value" {
|
||||
t.Fatalf("enabled = %+v, %v", enabled, err)
|
||||
}
|
||||
for name, values := range map[string]map[string]string{
|
||||
"missing URL": {"SEMANTIC_MATCHING_ENABLED": "true"},
|
||||
"credentials": {"ML_SERVICE_URL": "http://user:secret@ml:8000"},
|
||||
"path": {"ML_SERVICE_URL": "http://ml:8000/v1"},
|
||||
"scheme": {"ML_SERVICE_URL": "file:///tmp/ml"},
|
||||
"timeout": {"ML_REQUEST_TIMEOUT": "0s"},
|
||||
"circuit": {"ML_CIRCUIT_FAILURES": "0"},
|
||||
"interval": {"REPOSITORY_CHECK_INTERVAL": "48h"},
|
||||
"token whitespace": {"GITHUB_TOKEN": "a b"},
|
||||
} {
|
||||
_, err := LoadSemanticSettings(lookupOf(values))
|
||||
if err == nil {
|
||||
t.Errorf("%s: invalid settings were accepted", name)
|
||||
continue
|
||||
}
|
||||
if strings.Contains(err.Error(), "secret") || strings.Contains(err.Error(), "a b") {
|
||||
t.Errorf("%s: the error quotes the value: %v", name, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user