All checks were successful
CI / changes (push) Successful in 19s
CI / test (push) Successful in 24s
CI / build-ai-gateway (push) Successful in 1m6s
CI / build-ha-gateway (push) Successful in 1m3s
CI / build-discord-bot (push) Successful in 1m4s
CI / build-alexa-bridge (push) Successful in 1m15s
CI / build-tts-gateway (push) Successful in 1m5s
CI / build-tts-sidecar (push) Has been skipped
CI / build-tts-model (push) Has been skipped
- Implemented SetTemperature in ClimateService for setting an absolute target temperature. - Updated ClimateServiceClient and ClimateServiceServer interfaces to include SetTemperature. - Added corresponding handler and tests for SetTemperature in ClimateGRPC. - Modified ClimateApp to handle SetTemperature requests without clamping. - Updated climate.proto to define SetTemperatureRequest message. - Adjusted Dockerfiles to include alexa-bridge dependencies.
61 lines
1.7 KiB
Go
61 lines
1.7 KiB
Go
package entities
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gitea.nik4nao.com/nik/home-services/alexa-bridge/internal/core/domain"
|
|
)
|
|
|
|
func TestResolverResolve(t *testing.T) {
|
|
r := NewResolver()
|
|
|
|
t.Run("empty resolver misses", func(t *testing.T) {
|
|
if _, ok := r.Resolve("Living Room Lamp"); ok {
|
|
t.Fatal("Resolve() ok = true on empty resolver, want false")
|
|
}
|
|
})
|
|
|
|
r.Replace([]domain.Entity{
|
|
{EntityID: "light.living_room", FriendlyName: "Living Room Lamp", Domain: "light"},
|
|
{EntityID: "switch.fan", FriendlyName: "Fan", Domain: "switch"},
|
|
})
|
|
|
|
t.Run("exact match after normalization", func(t *testing.T) {
|
|
e, ok := r.Resolve(" living room lamp ")
|
|
if !ok {
|
|
t.Fatal("Resolve() ok = false, want true")
|
|
}
|
|
if e.EntityID != "light.living_room" {
|
|
t.Fatalf("EntityID = %q, want %q", e.EntityID, "light.living_room")
|
|
}
|
|
})
|
|
|
|
t.Run("case-sensitivity does not matter", func(t *testing.T) {
|
|
if _, ok := r.Resolve("LIVING ROOM LAMP"); !ok {
|
|
t.Fatal("Resolve() ok = false, want true")
|
|
}
|
|
})
|
|
|
|
t.Run("no fuzzy match", func(t *testing.T) {
|
|
if _, ok := r.Resolve("living room light"); ok {
|
|
t.Fatal("Resolve() ok = true for a non-exact name, want false (exact-match only, see plan.md Decisions #5)")
|
|
}
|
|
})
|
|
|
|
t.Run("unknown name misses", func(t *testing.T) {
|
|
if _, ok := r.Resolve("kitchen"); ok {
|
|
t.Fatal("Resolve() ok = true, want false")
|
|
}
|
|
})
|
|
|
|
t.Run("Replace fully overwrites the previous snapshot", func(t *testing.T) {
|
|
r.Replace([]domain.Entity{{EntityID: "light.bedroom", FriendlyName: "Bedroom", Domain: "light"}})
|
|
if _, ok := r.Resolve("fan"); ok {
|
|
t.Fatal("Resolve() found stale entry after Replace, want it gone")
|
|
}
|
|
if _, ok := r.Resolve("bedroom"); !ok {
|
|
t.Fatal("Resolve() ok = false for newly replaced entry, want true")
|
|
}
|
|
})
|
|
}
|