Skip to content
Snippets Groups Projects
Commit 97f3d832 authored by Johannes Borgen's avatar Johannes Borgen
Browse files

now sort on month instead of day

parent d264e4ee
No related branches found
No related tags found
1 merge request!4Finished app
...@@ -4,10 +4,30 @@ import ( ...@@ -4,10 +4,30 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"net/http" "net/http"
"net/http/httptest"
"strconv" "strconv"
"testing" "testing"
) )
func TestWeatherHandler(t *testing.T) {
// make new request to status handler
req, err := http.NewRequest("GET", "/weather?lat=some&long=bogus", nil)
if err != nil {
t.Fatal(err)
}
rr := httptest.NewRecorder()
// check if response is 200
if status := rr.Code; status != http.StatusOK {
t.Errorf("handler returned wrong status code: got %v want %v",
status, http.StatusOK)
}
handler := http.HandlerFunc(WeatherHandler)
handler.ServeHTTP(rr, req)
}
func TestGetSingleForecast(t *testing.T) { func TestGetSingleForecast(t *testing.T) {
latitude := 58.8569687273594 latitude := 58.8569687273594
longitude := 5.85660630854479 longitude := 5.85660630854479
...@@ -27,6 +47,7 @@ func TestGetSingleForecast(t *testing.T) { ...@@ -27,6 +47,7 @@ func TestGetSingleForecast(t *testing.T) {
if err !=nil && err.Error() != expected.Error() { if err !=nil && err.Error() != expected.Error() {
t.Error(err) t.Error(err)
} }
} }
func TestParseWeatherData(t *testing.T) { func TestParseWeatherData(t *testing.T) {
...@@ -89,7 +110,7 @@ func TestParseWeatherData(t *testing.T) { ...@@ -89,7 +110,7 @@ func TestParseWeatherData(t *testing.T) {
if len(test.ForecastMap) == 0 { if len(test.ForecastMap) == 0 {
t.Error("Error in parsing data") t.Error("Error in parsing data")
} }
if test.ForecastMap["21/11/19: 08:00"] != "3 Celsius" && test.RainMap["21/11/19: 09:00 to 12:00"] != "4.5 mm"{ if test.ForecastMap["11/21/19: 08:00"] != "3 Celsius" && test.RainMap["11/21/19: 09:00 to 12:00"] != "4.5 mm"{
t.Error("Data not present in FinalReport") t.Error("Data not present in FinalReport")
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment