mirror of
https://github.com/EricNeid/go-openweather.git
synced 2025-01-10 15:05:07 +00:00
Changed module name
This commit is contained in:
parent
a96f5562bb
commit
739889c07b
@ -1,9 +1,9 @@
|
||||
# go - openweatherapi
|
||||
# About
|
||||
|
||||
This Repo contains golang library to query OpenWetherMaps (<http://openweathermap.org/>) for weather information.
|
||||
|
||||
* current weather: http://openweathermap.org/current
|
||||
* 5 days forecast: http://openweathermap.org/forecast5
|
||||
* current weather: <http://openweathermap.org/current>
|
||||
* 5 days forecast: <http://openweathermap.org/forecast5>
|
||||
|
||||
## Install
|
||||
|
||||
|
18
api_test.go
18
api_test.go
@ -4,7 +4,7 @@ import (
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
|
||||
"github.com/EricNeid/go-openweather/internal/test"
|
||||
"EricNeid/go-openweather/internal/verify"
|
||||
)
|
||||
|
||||
const apiKeyFile = "testdata/api.key"
|
||||
@ -29,8 +29,8 @@ func TestForecastRaw(t *testing.T) {
|
||||
// action
|
||||
resp, err := q.DailyForecast5Raw()
|
||||
// verify
|
||||
test.Ok(t, err)
|
||||
test.Assert(t, len(resp) > 0, "Received empty response")
|
||||
verify.Ok(t, err)
|
||||
verify.Assert(t, len(resp) > 0, "Received empty response")
|
||||
}
|
||||
|
||||
func TestWeatherRaw(t *testing.T) {
|
||||
@ -39,8 +39,8 @@ func TestWeatherRaw(t *testing.T) {
|
||||
// action
|
||||
resp, err := q.WeatherRaw()
|
||||
// verify
|
||||
test.Ok(t, err)
|
||||
test.Assert(t, len(resp) > 0, "Received empty response")
|
||||
verify.Ok(t, err)
|
||||
verify.Assert(t, len(resp) > 0, "Received empty response")
|
||||
}
|
||||
|
||||
func TestWeather(t *testing.T) {
|
||||
@ -49,8 +49,8 @@ func TestWeather(t *testing.T) {
|
||||
// action
|
||||
data, err := q.Weather()
|
||||
// verify
|
||||
test.Ok(t, err)
|
||||
test.Equals(t, "Berlin", data.Name)
|
||||
verify.Ok(t, err)
|
||||
verify.Equals(t, "Berlin", data.Name)
|
||||
}
|
||||
|
||||
func TestDailyForecast(t *testing.T) {
|
||||
@ -59,6 +59,6 @@ func TestDailyForecast(t *testing.T) {
|
||||
// action
|
||||
data, err := q.DailyForecast5()
|
||||
// verify
|
||||
test.Ok(t, err)
|
||||
test.Equals(t, "Berlin", data.City.Name)
|
||||
verify.Ok(t, err)
|
||||
verify.Equals(t, "Berlin", data.City.Name)
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
"github.com/EricNeid/go-openweather"
|
||||
"EricNeid/go-openweather"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
2
go.mod
2
go.mod
@ -1,3 +1,3 @@
|
||||
module github.com/EricNeid/go-openweather
|
||||
module EricNeid/go-openweather
|
||||
|
||||
go 1.13
|
||||
|
@ -1,4 +1,4 @@
|
||||
package test
|
||||
package verify
|
||||
|
||||
import (
|
||||
"fmt"
|
@ -3,7 +3,7 @@ package openweather
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/EricNeid/go-openweather/internal/test"
|
||||
"EricNeid/go-openweather/internal/verify"
|
||||
)
|
||||
|
||||
func TestNewQueryForCity(t *testing.T) {
|
||||
@ -13,17 +13,17 @@ func TestNewQueryForCity(t *testing.T) {
|
||||
// action
|
||||
q := NewQueryForCity(apiKey, location)
|
||||
// verify
|
||||
test.Equals(t, apiKey, q.APIKey)
|
||||
test.Equals(t, location, q.Query)
|
||||
test.Equals(t, "metric", q.Unit)
|
||||
test.Equals(t, queryTypeCity, q.queryType)
|
||||
verify.Equals(t, apiKey, q.APIKey)
|
||||
verify.Equals(t, location, q.Query)
|
||||
verify.Equals(t, "metric", q.Unit)
|
||||
verify.Equals(t, queryTypeCity, q.queryType)
|
||||
|
||||
// arrange
|
||||
unit := "imperial"
|
||||
// action
|
||||
q = NewQueryForCity(apiKey, location, unit)
|
||||
// verify
|
||||
test.Equals(t, unit, q.Unit)
|
||||
verify.Equals(t, unit, q.Unit)
|
||||
}
|
||||
|
||||
func TestNewQueryForZip(t *testing.T) {
|
||||
@ -33,9 +33,9 @@ func TestNewQueryForZip(t *testing.T) {
|
||||
// action
|
||||
q := NewQueryForZip(apiKey, zip)
|
||||
// verify
|
||||
test.Equals(t, apiKey, q.APIKey)
|
||||
test.Equals(t, zip, q.Query)
|
||||
test.Equals(t, queryTypeZip, q.queryType)
|
||||
verify.Equals(t, apiKey, q.APIKey)
|
||||
verify.Equals(t, zip, q.Query)
|
||||
verify.Equals(t, queryTypeZip, q.queryType)
|
||||
}
|
||||
|
||||
func TestNewQueryForID(t *testing.T) {
|
||||
@ -45,9 +45,9 @@ func TestNewQueryForID(t *testing.T) {
|
||||
// action
|
||||
q := NewQueryForID(apiKey, id)
|
||||
// verify
|
||||
test.Equals(t, apiKey, q.APIKey)
|
||||
test.Equals(t, id, q.Query)
|
||||
test.Equals(t, queryTypeID, q.queryType)
|
||||
verify.Equals(t, apiKey, q.APIKey)
|
||||
verify.Equals(t, id, q.Query)
|
||||
verify.Equals(t, queryTypeID, q.queryType)
|
||||
}
|
||||
|
||||
func TestNewQueryForLocation(t *testing.T) {
|
||||
@ -58,7 +58,7 @@ func TestNewQueryForLocation(t *testing.T) {
|
||||
// action
|
||||
q := NewQueryForLocation(apiKey, lat, lon)
|
||||
// verify
|
||||
test.Equals(t, apiKey, q.APIKey)
|
||||
test.Equals(t, lat+"|"+lon, q.Query)
|
||||
test.Equals(t, queryTypeGeo, q.queryType)
|
||||
verify.Equals(t, apiKey, q.APIKey)
|
||||
verify.Equals(t, lat+"|"+lon, q.Query)
|
||||
verify.Equals(t, queryTypeGeo, q.queryType)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user