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