1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

fix: precedence in case of multiple matching language mappings (fix #172)

This commit is contained in:
Ferdinand Mütsch
2021-04-13 23:39:31 +02:00
parent f8e1453754
commit 20dd4cf0ab
3 changed files with 14 additions and 4 deletions

View File

@ -28,22 +28,28 @@ func TestHeartbeat_Augment(t *testing.T) {
testMappings := map[string]string{
"py": "Python3",
"foo": "Foo Script",
"php": "PHP 8",
"blade.php": "Blade",
}
sut1, sut2 := &Heartbeat{
sut1, sut2, sut3 := &Heartbeat{
Entity: "~/dev/file.py",
Language: "Python",
}, &Heartbeat{
Entity: "~/dev/file.blade.php",
Language: "unknown",
}, &Heartbeat{
Entity: "~/dev/file.php",
Language: "PHP",
}
sut1.Augment(testMappings)
sut2.Augment(testMappings)
sut3.Augment(testMappings)
assert.Equal(t, "Python3", sut1.Language)
assert.Equal(t, "Blade", sut2.Language)
assert.Equal(t, "PHP 8", sut3.Language)
}
func TestHeartbeat_GetKey(t *testing.T) {