31 lines
1.4 KiB
Go
31 lines
1.4 KiB
Go
package domain_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"git.cin.su/m/Assistant/contracts/world"
|
|
"git.cin.su/m/Assistant/modules/world/domain"
|
|
)
|
|
|
|
func TestResolveCandidatesDoesNotAutoMergeAmbiguousPeopleOrSystems(t *testing.T) {
|
|
decision, candidates := domain.ResolveCandidates([]world.IdentityResolutionCandidate{
|
|
{ObjectRef: world.SemanticReference{OwnerNamespace: "world", SemanticKind: "person", StableID: "ivan-telegram"}, Confidence: 800},
|
|
{ObjectRef: world.SemanticReference{OwnerNamespace: "world", SemanticKind: "person", StableID: "ivan-crm"}, Confidence: 800},
|
|
}, 700)
|
|
if decision != world.ResolutionUnresolved || len(candidates) != 2 {
|
|
t.Fatalf("ambiguous result = %s, %#v", decision, candidates)
|
|
}
|
|
}
|
|
|
|
func TestVersionAndEnvironmentReferencesAreTyped(t *testing.T) {
|
|
version := world.SemanticReference{OwnerNamespace: "world", SemanticKind: "version", StableID: "unf-3"}
|
|
binding := world.VersionBinding{SubjectRef: world.SemanticReference{OwnerNamespace: "world", SemanticKind: "database", StableID: "company-a-unf"}, VersionRef: version, MatchMode: world.VersionExact}
|
|
if err := binding.Validate(); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
environment := world.EnvironmentReference{EnvironmentRef: world.SemanticReference{OwnerNamespace: "world", SemanticKind: "environment", StableID: "company-a-prod"}, VersionRef: &version}
|
|
if err := environment.Validate(); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|