From 739889c07bd0a9d55a5cb332f8b68d9a8a7e3f55 Mon Sep 17 00:00:00 2001 From: Eric Neidhardt Date: Wed, 22 Jan 2020 15:40:23 +0100 Subject: [PATCH 1/6] Changed module name --- README.md | 6 ++--- api_test.go | 18 ++++++------- cmd/openweatherclient/main.go | 2 +- go.mod | 2 +- internal/{test => verify}/testing_utils.go | 2 +- query_test.go | 30 +++++++++++----------- 6 files changed, 30 insertions(+), 30 deletions(-) rename internal/{test => verify}/testing_utils.go (98%) diff --git a/README.md b/README.md index 717244a..4ed0103 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# go - openweatherapi +# About This Repo contains golang library to query OpenWetherMaps () for weather information. -* current weather: http://openweathermap.org/current -* 5 days forecast: http://openweathermap.org/forecast5 +* current weather: +* 5 days forecast: ## Install diff --git a/api_test.go b/api_test.go index c799805..435caa0 100644 --- a/api_test.go +++ b/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) } diff --git a/cmd/openweatherclient/main.go b/cmd/openweatherclient/main.go index 976ce56..95a0f54 100644 --- a/cmd/openweatherclient/main.go +++ b/cmd/openweatherclient/main.go @@ -4,7 +4,7 @@ import ( "flag" "fmt" - "github.com/EricNeid/go-openweather" + "EricNeid/go-openweather" ) func main() { diff --git a/go.mod b/go.mod index 0690572..7232967 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ -module github.com/EricNeid/go-openweather +module EricNeid/go-openweather go 1.13 diff --git a/internal/test/testing_utils.go b/internal/verify/testing_utils.go similarity index 98% rename from internal/test/testing_utils.go rename to internal/verify/testing_utils.go index 3497485..9265105 100644 --- a/internal/test/testing_utils.go +++ b/internal/verify/testing_utils.go @@ -1,4 +1,4 @@ -package test +package verify import ( "fmt" diff --git a/query_test.go b/query_test.go index 6a1c20b..7530352 100644 --- a/query_test.go +++ b/query_test.go @@ -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) } From 3693783e3ca71ccbfd881bbd840ceac65714ad09 Mon Sep 17 00:00:00 2001 From: Eric Neidhardt Date: Wed, 22 Jan 2020 15:50:41 +0100 Subject: [PATCH 2/6] Fixed missing dot in import path --- api_test.go | 2 +- cmd/openweatherclient/main.go | 2 +- go.mod | 2 +- query_test.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/api_test.go b/api_test.go index 435caa0..9a027ea 100644 --- a/api_test.go +++ b/api_test.go @@ -4,7 +4,7 @@ import ( "io/ioutil" "testing" - "EricNeid/go-openweather/internal/verify" + "github.com/EricNeid/go-openweather/internal/verify" ) const apiKeyFile = "testdata/api.key" diff --git a/cmd/openweatherclient/main.go b/cmd/openweatherclient/main.go index 95a0f54..976ce56 100644 --- a/cmd/openweatherclient/main.go +++ b/cmd/openweatherclient/main.go @@ -4,7 +4,7 @@ import ( "flag" "fmt" - "EricNeid/go-openweather" + "github.com/EricNeid/go-openweather" ) func main() { diff --git a/go.mod b/go.mod index 7232967..0690572 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ -module EricNeid/go-openweather +module github.com/EricNeid/go-openweather go 1.13 diff --git a/query_test.go b/query_test.go index 7530352..7c63d9e 100644 --- a/query_test.go +++ b/query_test.go @@ -3,7 +3,7 @@ package openweather import ( "testing" - "EricNeid/go-openweather/internal/verify" + "github.com/EricNeid/go-openweather/internal/verify" ) func TestNewQueryForCity(t *testing.T) { From 04f54aca88ee93eca5d804ae05eca2bd5e9d8633 Mon Sep 17 00:00:00 2001 From: Eric Neidhardt Date: Fri, 17 Jul 2020 09:18:32 +0200 Subject: [PATCH 3/6] Separate unit and integration tests --- README.md | 6 ++++++ api_test.go => integration_test.go | 2 ++ query_test.go | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) rename api_test.go => integration_test.go (98%) diff --git a/README.md b/README.md index 4ed0103..8284e48 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ +[![Go Report Card](https://goreportcard.com/badge/github.com/EricNeid/go-openweather?style=flat-square)](https://goreportcard.com/report/github.com/EricNeid/go-openweather) +![Go](https://github.com/EricNeid/go-openweather/workflows/Go/badge.svg) +[![Go Doc](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat-square)](http://godoc.org/github.com/EricNeid/go-openweather) +[![Release](https://img.shields.io/github/release/EricNeid/go-openweather.svg?style=flat-square)](https://github.com/EricNeid/go-openweather/releases/latest) +[![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/EricNeid/go-openweather) + # About This Repo contains golang library to query OpenWetherMaps () for weather information. diff --git a/api_test.go b/integration_test.go similarity index 98% rename from api_test.go rename to integration_test.go index 9a027ea..d18503d 100644 --- a/api_test.go +++ b/integration_test.go @@ -1,3 +1,5 @@ +// +build integration + package openweather import ( diff --git a/query_test.go b/query_test.go index 7c63d9e..80e452a 100644 --- a/query_test.go +++ b/query_test.go @@ -9,7 +9,7 @@ import ( func TestNewQueryForCity(t *testing.T) { // arrange apiKey := "testKey" - location := cityBerlin + location := "Berlin,de" // action q := NewQueryForCity(apiKey, location) // verify From 504cad4e7f9db50a2178afe773e19c41602bcc0f Mon Sep 17 00:00:00 2001 From: Eric Neidhardt Date: Fri, 17 Jul 2020 09:19:11 +0200 Subject: [PATCH 4/6] Create go.yml --- .github/workflows/go.yml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/go.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..d31e87f --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,37 @@ +name: Go + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + + build: + name: Build + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.x + uses: actions/setup-go@v2 + with: + go-version: ^1.13 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Get dependencies + run: | + go get -v -t -d ./... + if [ -f Gopkg.toml ]; then + curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh + dep ensure + fi + + - name: Build + run: go build -v . + + - name: Test + run: go test -v . From 886604142c05210107195e22347c111656feae92 Mon Sep 17 00:00:00 2001 From: Eric Neidhardt Date: Fri, 17 Jul 2020 07:42:09 +0000 Subject: [PATCH 5/6] Update gitpod configuration --- .gitpod.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitpod.yml diff --git a/.gitpod.yml b/.gitpod.yml new file mode 100644 index 0000000..d473f31 --- /dev/null +++ b/.gitpod.yml @@ -0,0 +1,2 @@ +tasks: + - init: go get && make build && make test From 87d96828d2fa179ad387eebf05047ec047a4234f Mon Sep 17 00:00:00 2001 From: Eric Neidhardt Date: Fri, 17 Jul 2020 14:00:26 +0200 Subject: [PATCH 6/6] Markdown lint --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 8284e48..9cd2f05 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ + [![Go Report Card](https://goreportcard.com/badge/github.com/EricNeid/go-openweather?style=flat-square)](https://goreportcard.com/report/github.com/EricNeid/go-openweather) ![Go](https://github.com/EricNeid/go-openweather/workflows/Go/badge.svg) [![Go Doc](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat-square)](http://godoc.org/github.com/EricNeid/go-openweather)