Skip to content
This repository was archived by the owner on Mar 22, 2025. It is now read-only.

Commit 8b0d23c

Browse files
committed
fixed conflicts from dev -> Comfortstat
2 parents 8e3f494 + 6790712 commit 8b0d23c

22 files changed

+3469
-178
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Dockerfile
2+
.git*

.github/workflows/main.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Tests and Linters
1+
name: Linters, Spellcheck, and Tests
22

33
on:
44
push:
@@ -7,7 +7,7 @@ on:
77
jobs:
88
Linters:
99
runs-on: ubuntu-latest
10-
timeout-minutes: 10
10+
timeout-minutes: 2
1111
steps:
1212
- uses: actions/checkout@v4
1313
- name: Setup go
@@ -19,9 +19,16 @@ jobs:
1919
- name: Run linters
2020
run: make lint
2121

22+
Spellcheck:
23+
runs-on: ubuntu-latest
24+
timeout-minutes: 2
25+
steps:
26+
- uses: actions/checkout@v4
27+
- uses: crate-ci/[email protected]
28+
2229
Tests:
2330
runs-on: ubuntu-latest
24-
timeout-minutes: 10
31+
timeout-minutes: 2
2532
steps:
2633
- uses: actions/checkout@v4
2734
- name: Setup go

Comfortstat/Comfortstat.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func main() {
2020
// instantiate the System
2121
sys := components.NewSystem("Comfortstat", ctx)
2222

23-
// Instatiate the Capusle
23+
// Instantiate the Capsule
2424
sys.Husk = &components.Husk{
2525
Description: " is a controller for a consumed servo motor position based on a consumed temperature",
2626
Certificate: "ABCD",
@@ -31,7 +31,7 @@ func main() {
3131

3232
// instantiate a template unit asset
3333
assetTemplate := initTemplate()
34-
// Calling initAPI() starts the pricefeedbackloop that fetches the current electrisity price for the particular hour
34+
// Calling initAPI() starts the pricefeedbackloop that fetches the current electricity price for the particular hour
3535
initAPI()
3636
time.Sleep(1 * time.Second)
3737
assetName := assetTemplate.GetName()
@@ -69,7 +69,7 @@ func main() {
6969
time.Sleep(2 * time.Second) // allow the go routines to be executed, which might take more time than the main routine to end
7070
}
7171

72-
// Serving handles the resources services. NOTE: it exepcts those names from the request URL path
72+
// Serving handles the resources services. NOTE: it expects those names from the request URL path
7373
func (t *UnitAsset) Serving(w http.ResponseWriter, r *http.Request, servicePath string) {
7474
switch servicePath {
7575
case "MinTemperature":
@@ -103,7 +103,7 @@ func (rsc *UnitAsset) httpSetSEKPrice(w http.ResponseWriter, r *http.Request) {
103103
}
104104
}
105105

106-
// All these functions below handles HTTP "PUT" or "GET" requests to modefy or retrieve the MAX/MIN temprature/price and desierd temprature
106+
// All these functions below handles HTTP "PUT" or "GET" requests to modefy or retrieve the MAX/MIN temprature/price and desierd temperature
107107
// For the PUT case - the "HTTPProcessSetRequest(w, r)" is called to prosses the data given from the user and if no error,
108108
// call the set functions in things.go with the value witch updates the value in the struct
109109
func (rsc *UnitAsset) httpSetMinTemp(w http.ResponseWriter, r *http.Request) {
@@ -112,7 +112,7 @@ func (rsc *UnitAsset) httpSetMinTemp(w http.ResponseWriter, r *http.Request) {
112112
sig, err := usecases.HTTPProcessSetRequest(w, r)
113113
if err != nil {
114114
//log.Println("Error with the setting request of the position ", err)
115-
http.Error(w, "request incorreclty formated", http.StatusBadRequest)
115+
http.Error(w, "request incorrectly formatted", http.StatusBadRequest)
116116
return
117117

118118
}
@@ -130,7 +130,7 @@ func (rsc *UnitAsset) httpSetMaxTemp(w http.ResponseWriter, r *http.Request) {
130130
sig, err := usecases.HTTPProcessSetRequest(w, r)
131131
if err != nil {
132132
//log.Println("Error with the setting request of the position ", err)
133-
http.Error(w, "request incorreclty formated", http.StatusBadRequest)
133+
http.Error(w, "request incorrectly formatted", http.StatusBadRequest)
134134
return
135135
}
136136
rsc.setMaxTemp(sig)
@@ -148,7 +148,7 @@ func (rsc *UnitAsset) httpSetMinPrice(w http.ResponseWriter, r *http.Request) {
148148
sig, err := usecases.HTTPProcessSetRequest(w, r)
149149
if err != nil {
150150
//log.Println("Error with the setting request of the position ", err)
151-
http.Error(w, "request incorreclty formated", http.StatusBadRequest)
151+
http.Error(w, "request incorrectly formatted", http.StatusBadRequest)
152152
return
153153
}
154154
rsc.setMinPrice(sig)
@@ -167,7 +167,7 @@ func (rsc *UnitAsset) httpSetMaxPrice(w http.ResponseWriter, r *http.Request) {
167167
sig, err := usecases.HTTPProcessSetRequest(w, r)
168168
if err != nil {
169169
//log.Println("Error with the setting request of the position ", err)
170-
http.Error(w, "request incorreclty formated", http.StatusBadRequest)
170+
http.Error(w, "request incorrectly formatted", http.StatusBadRequest)
171171
return
172172
}
173173
rsc.setMaxPrice(sig)
@@ -186,7 +186,7 @@ func (rsc *UnitAsset) httpSetDesiredTemp(w http.ResponseWriter, r *http.Request)
186186
sig, err := usecases.HTTPProcessSetRequest(w, r)
187187
if err != nil {
188188
//log.Println("Error with the setting request of the position ", err)
189-
http.Error(w, "request incorreclty formated", http.StatusBadRequest)
189+
http.Error(w, "request incorrectly formatted", http.StatusBadRequest)
190190
return
191191
}
192192
rsc.setDesiredTemp(sig)
@@ -204,7 +204,7 @@ func (rsc *UnitAsset) httpSetUserTemp(w http.ResponseWriter, r *http.Request) {
204204
case "PUT":
205205
sig, err := usecases.HTTPProcessSetRequest(w, r)
206206
if err != nil {
207-
http.Error(w, "request incorrectly formated", http.StatusBadRequest)
207+
http.Error(w, "request incorrectly formatted", http.StatusBadRequest)
208208
return
209209
}
210210
rsc.setUserTemp(sig)
@@ -221,7 +221,7 @@ func (rsc *UnitAsset) httpSetRegion(w http.ResponseWriter, r *http.Request) {
221221
case "PUT":
222222
sig, err := usecases.HTTPProcessSetRequest(w, r)
223223
if err != nil {
224-
http.Error(w, "request incorrectly formated", http.StatusBadRequest)
224+
http.Error(w, "request incorrectly formatted", http.StatusBadRequest)
225225
return
226226
}
227227
rsc.setRegion(sig)

Comfortstat/Comfortstat_test.go

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ func TestHttpSetSEKPrice(t *testing.T) {
2929
version := strings.Contains(string(body), `"version": "SignalA_v1.0"`)
3030
// check results from above
3131
if value != true {
32-
t.Errorf("expected the statment to be true!")
32+
t.Errorf("expected the statement to be true!")
3333
}
3434
if unit != true {
3535
t.Errorf("expected the unit statement to be true!")
3636
}
3737
if version != true {
38-
t.Errorf("expected the version statment to be true!")
38+
t.Errorf("expected the version statement to be true!")
3939
}
4040
// Bad test case: default part of code
4141
w = httptest.NewRecorder()
@@ -97,13 +97,13 @@ func TestHttpSetMinTemp(t *testing.T) {
9797
version := strings.Contains(string(body), `"version": "SignalA_v1.0"`)
9898
// check the result from above
9999
if value != true {
100-
t.Errorf("expected the statment to be true!")
100+
t.Errorf("expected the statement to be true!")
101101
}
102102
if unit != true {
103103
t.Errorf("expected the unit statement to be true!")
104104
}
105105
if version != true {
106-
t.Errorf("expected the version statment to be true!")
106+
t.Errorf("expected the version statement to be true!")
107107
}
108108
// bad test case: default part of code
109109
// force the case to hit default statement but alter the method
@@ -165,13 +165,13 @@ func TestHttpSetMaxTemp(t *testing.T) {
165165
unit := strings.Contains(string(body), `"unit": "Celsius"`)
166166
version := strings.Contains(string(body), `"version": "SignalA_v1.0"`)
167167
if value != true {
168-
t.Errorf("expected the statment to be true!")
168+
t.Errorf("expected the statement to be true!")
169169
}
170170
if unit != true {
171171
t.Errorf("expected the unit statement to be true!")
172172
}
173173
if version != true {
174-
t.Errorf("expected the version statment to be true!")
174+
t.Errorf("expected the version statement to be true!")
175175
}
176176
// bad test case: default part of code
177177

@@ -233,13 +233,13 @@ func TestHttpSetMinPrice(t *testing.T) {
233233
unit := strings.Contains(string(body), `"unit": "SEK"`)
234234
version := strings.Contains(string(body), `"version": "SignalA_v1.0"`)
235235
if value != true {
236-
t.Errorf("expected the statment to be true!")
236+
t.Errorf("expected the statement to be true!")
237237
}
238238
if unit != true {
239239
t.Errorf("expected the unit statement to be true!")
240240
}
241241
if version != true {
242-
t.Errorf("expected the version statment to be true!")
242+
t.Errorf("expected the version statement to be true!")
243243
}
244244
// bad test case: default part of code
245245

@@ -303,13 +303,13 @@ func TestHttpSetMaxPrice(t *testing.T) {
303303
version := strings.Contains(string(body), `"version": "SignalA_v1.0"`)
304304

305305
if value != true {
306-
t.Errorf("expected the statment to be true!")
306+
t.Errorf("expected the statement to be true!")
307307
}
308308
if unit != true {
309309
t.Errorf("expected the unit statement to be true!")
310310
}
311311
if version != true {
312-
t.Errorf("expected the version statment to be true!")
312+
t.Errorf("expected the version statement to be true!")
313313
}
314314
// bad test case: default part of code
315315

@@ -377,13 +377,13 @@ func TestHttpSetDesiredTemp(t *testing.T) {
377377
version := strings.Contains(string(body), `"version": "SignalA_v1.0"`)
378378

379379
if value != true {
380-
t.Errorf("expected the statment to be true!")
380+
t.Errorf("expected the statement to be true!")
381381
}
382382
if unit != true {
383383
t.Errorf("expected the unit statement to be true!")
384384
}
385385
if version != true {
386-
t.Errorf("expected the version statment to be true!")
386+
t.Errorf("expected the version statement to be true!")
387387
}
388388
// bad test case: default part of code
389389

@@ -450,13 +450,13 @@ func TestHttpSetUserTemp(t *testing.T) {
450450
version := strings.Contains(string(body), `"version": "SignalA_v1.0"`)
451451

452452
if value != true {
453-
t.Errorf("expected the statment to be true!")
453+
t.Errorf("expected the statement to be true!")
454454
}
455455
if unit != true {
456456
t.Errorf("expected the unit statement to be true!")
457457
}
458458
if version != true {
459-
t.Errorf("expected the version statment to be true!")
459+
t.Errorf("expected the version statement to be true!")
460460
}
461461
// bad test case: default part of code
462462

@@ -477,9 +477,9 @@ func TestHttpSetRegion(t *testing.T) {
477477

478478
// creates a fake request body with JSON data
479479
w := httptest.NewRecorder()
480-
fakebody := bytes.NewReader([]byte(`{"value": 1, "unit": "RegionPoint", "version": "SignalA_v1.0"}`)) // converts the Jason data so it can be read
481-
r := httptest.NewRequest("PUT", "http://localhost:8670/Comfortstat/Set%20Values/Region", fakebody) // simulating a put request from a user to update the min temp
482-
r.Header.Set("Content-Type", "application/json") // basic setup to prevent the request to be rejected.
480+
fakebody := bytes.NewReader([]byte(`{"value": 1, "version": "SignalA_v1.0"}`)) // converts the Jason data so it can be read
481+
r := httptest.NewRequest("PUT", "http://localhost:8670/Comfortstat/Set%20Values/Region", fakebody) // simulating a put request from a user to update the min temp
482+
r.Header.Set("Content-Type", "application/json") // basic setup to prevent the request to be rejected.
483483
goodStatusCode := 200
484484

485485
ua.httpSetRegion(w, r)
@@ -494,7 +494,7 @@ func TestHttpSetRegion(t *testing.T) {
494494

495495
// creates a fake request body with JSON data
496496
w = httptest.NewRecorder()
497-
fakebody = bytes.NewReader([]byte(`{"123, "unit": "RegionPoint", "version": "SignalA_v1.0"}`)) // converts the Jason data so it can be read
497+
fakebody = bytes.NewReader([]byte(`{"123, "version": "SignalA_v1.0"}`)) // converts the Jason data so it can be read
498498
r = httptest.NewRequest("PUT", "http://localhost:8670/Comfortstat/Set%20Values/Region", fakebody) // simulating a put request from a user to update the min temp
499499
r.Header.Set("Content-Type", "application/json") // basic setup to prevent the request to be rejected.
500500

@@ -519,17 +519,13 @@ func TestHttpSetRegion(t *testing.T) {
519519
body, _ := io.ReadAll(resp.Body)
520520
// this is a simple check if the JSON response contains the specific value/unit/version
521521
value := strings.Contains(string(body), `"value": 1`)
522-
unit := strings.Contains(string(body), `"unit": "RegionPoint"`)
523522
version := strings.Contains(string(body), `"version": "SignalA_v1.0"`)
524523

525524
if value != true {
526-
t.Errorf("expected the statment to be true!")
527-
}
528-
if unit != true {
529-
t.Errorf("expected the unit statement to be true!")
525+
t.Errorf("expected the statement to be true!")
530526
}
531527
if version != true {
532-
t.Errorf("expected the version statment to be true!")
528+
t.Errorf("expected the version statement to be true!")
533529
}
534530
// bad test case: default part of code
535531

0 commit comments

Comments
 (0)