Skip to content

Commit 3845c19

Browse files
committed
Add functional test
1 parent cb0b74a commit 3845c19

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

docker-compose.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ services:
1010
- WS_ENVIRONMENT=${WS_ENVIRONMENT:-development}
1111
- WS_ZONES_FILE=${WS_ZONES_FILE:-/tmp/zones.yaml}
1212
- WS_AUTH_TOKEN=${WS_AUTH_TOKEN:-token}
13-
- WS_RAIN_SERVER_URL=${WS_RAIN_SERVER_URL:-http://rain_sensor:8080}
1413
- WS_DAILY_PROGRAMS_FILE=${WS_DAILY_PROGRAMS_FILE:-/tmp/daily_programs.yml}
1514
- WS_ODD_PROGRAMS_FILE=${WS_ODD_PROGRAMS_FILE:-/tmp/odd_programs.yml}
1615
- WS_EVEN_PROGRAMS_FILE=${WS_EVEN_PROGRAMS_FILE:-/tmp/even_programs.yml}

tests/functional/programs_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,33 @@ func TestPrograms(t *testing.T) {
125125
readResponse(t, resp, &schema)
126126
})
127127
})
128+
t.Run(`Given an update temperature program endpoint,
129+
when a request is sent`, func(t *testing.T) {
130+
t.Run(`without authorization,
131+
then it returns an authorized`, func(t *testing.T) {
132+
resp, err = buildRequestAndSend(ctx, nil, nil, http2.MethodPut, "/programs/temperature/20", cl)
133+
require.NoError(t, err)
134+
require.Equal(t, http2.StatusUnauthorized, resp.StatusCode)
135+
})
136+
137+
t.Run(`with authorization,
138+
then it returns an ok`, func(t *testing.T) {
139+
updateTemp := http.UpdateTemperatureProgramRequestJson{
140+
{
141+
Executions: []http.UpdateExecutionTemperatureRequest{
142+
{
143+
Seconds: 10,
144+
Zones: []string{zo.Id()},
145+
},
146+
},
147+
Hour: "17:00",
148+
},
149+
}
150+
resp, err = buildRequestAndSend(ctx, updateTemp, authorizationHeader(), http2.MethodPut, "/programs/temperature/20", cl)
151+
require.NoError(t, err)
152+
require.Equal(t, http2.StatusOK, resp.StatusCode)
153+
})
154+
})
128155
t.Run(`Given a remove weekly program endpoint,
129156
when a request is sent`, func(t *testing.T) {
130157
t.Run(`without authorization,

0 commit comments

Comments
 (0)