Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
cloudProject
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Job Bahner
cloudProject
Commits
97f3d832
Commit
97f3d832
authored
5 years ago
by
Johannes Borgen
Browse files
Options
Downloads
Patches
Plain Diff
now sort on month instead of day
parent
d264e4ee
No related branches found
No related tags found
1 merge request
!4
Finished app
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
weather_test.go
+22
-1
22 additions, 1 deletion
weather_test.go
with
22 additions
and
1 deletion
weather_test.go
+
22
−
1
View file @
97f3d832
...
@@ -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
[
"
2
1/
1
1/19: 08:00"
]
!=
"3 Celsius"
&&
test
.
RainMap
[
"
2
1/
1
1/19: 09:00 to 12:00"
]
!=
"4.5 mm"
{
if
test
.
ForecastMap
[
"
1
1/
2
1/19: 08:00"
]
!=
"3 Celsius"
&&
test
.
RainMap
[
"
1
1/
2
1/19: 09:00 to 12:00"
]
!=
"4.5 mm"
{
t
.
Error
(
"Data not present in FinalReport"
)
t
.
Error
(
"Data not present in FinalReport"
)
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment