-
Notifications
You must be signed in to change notification settings - Fork 0
/
apiclient_test.go
48 lines (41 loc) · 1.12 KB
/
apiclient_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package darksky_test
import (
"os"
"testing"
"time"
"github.com/sxg/DarkSky"
)
func TestNewAPIClient(t *testing.T) {
var client = darksky.NewAPIClient(os.Getenv("FORECAST_IO_API_KEY"))
if client == nil {
t.Error("couldn't create a new API client")
}
}
func TestAPIClientSetUnits(t *testing.T) {
var client = darksky.NewAPIClient(os.Getenv("FORECAST_IO_API_KEY"))
client.Units = darksky.UnitsSI
if client.Units != darksky.UnitsSI {
t.Error("couldn't set units on API client")
}
}
func TestAPIClientSetLanguage(t *testing.T) {
var client = darksky.NewAPIClient(os.Getenv("FORECAST_IO_API_KEY"))
client.Language = darksky.LanguageFrench
if client.Language != darksky.LanguageFrench {
t.Error("couldn't set language on API client")
}
}
func TestGetForecast(t *testing.T) {
var client = darksky.NewAPIClient(os.Getenv("FORECAST_IO_API_KEY"))
_, err := client.GetForecast(30, 30)
if err != nil {
t.Error(err)
}
}
func TestGetForecastAtTime(t *testing.T) {
var client = darksky.NewAPIClient(os.Getenv("FORECAST_IO_API_KEY"))
_, err := client.GetForecastAtTime(30, 30, time.Now())
if err != nil {
t.Error(err)
}
}