From d8c19d0c6d950545c7f8e1246f43902a782102e3 Mon Sep 17 00:00:00 2001 From: lnu Date: Wed, 1 Sep 2021 06:54:27 +0200 Subject: [PATCH] fix(owm): icon display at night Icon id is different for day/night --- src/segment_owm.go | 18 ++++++++++++ src/segment_owm_test.go | 64 +++++++++++++++++++++++++++++++++++------ 2 files changed, 73 insertions(+), 9 deletions(-) diff --git a/src/segment_owm.go b/src/segment_owm.go index 08aff3e3d26e..7584310449e8 100644 --- a/src/segment_owm.go +++ b/src/segment_owm.go @@ -80,22 +80,40 @@ func (d *owm) setStatus() error { d.temperature = q.temperature.Value icon := "" switch q.Data[0].TypeID { + case "01n": + fallthrough case "01d": icon = "\ufa98" + case "02n": + fallthrough case "02d": icon = "\ufa94" + case "03n": + fallthrough case "03d": icon = "\ue33d" + case "04n": + fallthrough case "04d": icon = "\ue312" + case "09n": + fallthrough case "09d": icon = "\ufa95" + case "10n": + fallthrough case "10d": icon = "\ue308" + case "11n": + fallthrough case "11d": icon = "\ue31d" + case "13n": + fallthrough case "13d": icon = "\ue31a" + case "50n": + fallthrough case "50d": icon = "\ue313" } diff --git a/src/segment_owm_test.go b/src/segment_owm_test.go index ffc4f8387288..513e2cdeb536 100644 --- a/src/segment_owm_test.go +++ b/src/segment_owm_test.go @@ -66,50 +66,96 @@ func TestOWMSegmentIcons(t *testing.T) { ExpectedIconString string }{ { - Case: "Sunny Display", + Case: "Sunny Display day", IconID: "01d", ExpectedIconString: "\ufa98", }, { - Case: "Light clouds Display", + Case: "Light clouds Display day", IconID: "02d", ExpectedIconString: "\ufa94", }, { - Case: "Cloudy Display", + Case: "Cloudy Display day", IconID: "03d", ExpectedIconString: "\ue33d", }, { - Case: "Broken Clouds Display", + Case: "Broken Clouds Display day", IconID: "04d", ExpectedIconString: "\ue312", }, { - Case: "Shower Rain Display", + Case: "Shower Rain Display day", IconID: "09d", ExpectedIconString: "\ufa95", }, { - Case: "Rain Display", + Case: "Rain Display day", IconID: "10d", ExpectedIconString: "\ue308", }, { - Case: "Thunderstorm Display", + Case: "Thunderstorm Display day", IconID: "11d", ExpectedIconString: "\ue31d", }, { - Case: "Snow Display", + Case: "Snow Display day", IconID: "13d", ExpectedIconString: "\ue31a", }, { - Case: "Fog Display", + Case: "Fog Display day", IconID: "50d", ExpectedIconString: "\ue313", }, + + { + Case: "Sunny Display night", + IconID: "01n", + ExpectedIconString: "\ufa98", + }, + { + Case: "Light clouds Display night", + IconID: "02n", + ExpectedIconString: "\ufa94", + }, + { + Case: "Cloudy Display night", + IconID: "03n", + ExpectedIconString: "\ue33d", + }, + { + Case: "Broken Clouds Display night", + IconID: "04n", + ExpectedIconString: "\ue312", + }, + { + Case: "Shower Rain Display night", + IconID: "09n", + ExpectedIconString: "\ufa95", + }, + { + Case: "Rain Display night", + IconID: "10n", + ExpectedIconString: "\ue308", + }, + { + Case: "Thunderstorm Display night", + IconID: "11n", + ExpectedIconString: "\ue31d", + }, + { + Case: "Snow Display night", + IconID: "13n", + ExpectedIconString: "\ue31a", + }, + { + Case: "Fog Display night", + IconID: "50n", + ExpectedIconString: "\ue313", + }, } for _, tc := range cases {