mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-28 04:19:41 -08:00
parent
69856f4464
commit
9238f3adbf
|
@ -4,6 +4,7 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"oh-my-posh/environment"
|
||||
"oh-my-posh/properties"
|
||||
)
|
||||
|
@ -12,7 +13,7 @@ type Owm struct {
|
|||
props properties.Properties
|
||||
env environment.Environment
|
||||
|
||||
Temperature float64
|
||||
Temperature int
|
||||
Weather string
|
||||
URL string
|
||||
units string
|
||||
|
@ -106,7 +107,7 @@ func (d *Owm) setStatus() error {
|
|||
}
|
||||
id := q.Data[0].TypeID
|
||||
|
||||
d.Temperature = q.temperature.Value
|
||||
d.Temperature = int(math.Round(q.temperature.Value))
|
||||
icon := ""
|
||||
switch id {
|
||||
case "01n":
|
||||
|
|
|
@ -182,7 +182,7 @@ func TestOWMSegmentIcons(t *testing.T) {
|
|||
for _, tc := range cases {
|
||||
env := &mock.MockedEnvironment{}
|
||||
|
||||
response := fmt.Sprintf(`{"weather":[{"icon":"%s"}],"main":{"temp":20}}`, tc.IconID)
|
||||
response := fmt.Sprintf(`{"weather":[{"icon":"%s"}],"main":{"temp":20.3}}`, tc.IconID)
|
||||
expectedString := fmt.Sprintf("%s (20°C)", tc.ExpectedIconString)
|
||||
|
||||
env.On("HTTPRequest", OWMAPIURL).Return([]byte(response), nil)
|
||||
|
@ -205,7 +205,7 @@ func TestOWMSegmentIcons(t *testing.T) {
|
|||
for _, tc := range cases {
|
||||
env := &mock.MockedEnvironment{}
|
||||
|
||||
response := fmt.Sprintf(`{"weather":[{"icon":"%s"}],"main":{"temp":20}}`, tc.IconID)
|
||||
response := fmt.Sprintf(`{"weather":[{"icon":"%s"}],"main":{"temp":20.3}}`, tc.IconID)
|
||||
expectedString := fmt.Sprintf("[%s (20°C)](http://api.openweathermap.org/data/2.5/weather?q=AMSTERDAM,NL&units=metric&appid=key)", tc.ExpectedIconString)
|
||||
|
||||
env.On("HTTPRequest", OWMAPIURL).Return([]byte(response), nil)
|
||||
|
|
|
@ -60,7 +60,7 @@ properties below - defaults to `{{.Weather}} ({{.Temperature}}{{.UnitIcon}})`
|
|||
### Properties
|
||||
|
||||
- `.Weather`: `string` - the current weather icon
|
||||
- `.Temperature`: `string` - the current temperature
|
||||
- `.Temperature`: `int` - the current temperature
|
||||
- `.UnitIcon`: `string` - the current unit icon(based on units property)
|
||||
- `.URL`: `string` - the url of the current api call
|
||||
|
||||
|
|
Loading…
Reference in a new issue