Skip to content

Commit

Permalink
add integration tests and CORS header
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-goebel committed Jul 11, 2023
1 parent bf3dd0c commit 20fa297
Show file tree
Hide file tree
Showing 6 changed files with 423 additions and 240 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Integration Test

on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *' # Runs the job at 00:00 UTC every day

jobs:
app-integration-test:
uses: eliona-smart-building-assistant/app-integration-tests/.github/workflows/app-integration-test.yml@main
secrets: inherit
20 changes: 11 additions & 9 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package main
import (
"context"
"github.com/eliona-smart-building-assistant/go-utils/common"
utilshttp "github.com/eliona-smart-building-assistant/go-utils/http"
"github.com/eliona-smart-building-assistant/go-utils/log"
"hailo/apiserver"
"hailo/apiservices"
Expand Down Expand Up @@ -56,12 +57,12 @@ func collectData() {
if !conf.IsConfigActive(config) {
conf.SetConfigActiveState(context.Background(), config, true)
log.Info("Hailo", "Collecting %d initialized with config:\n"+
"FDS Fds Endpoint: %s\n"+
"FDS Fds Auth Server: %s\n"+
"FDS Fds Endpoint: %v\n"+
"FDS Fds Auth Server: %v\n"+
"Auth Timeout: %d\n"+
"Request Timeout: %d",
config.Id,
config.FdsServer,
*config.FdsServer,
config.AuthServer,
config.AuthTimeout,
config.RequestTimeout)
Expand Down Expand Up @@ -89,12 +90,13 @@ func collectData() {
// listenApiRequests starts an API server and listen for API requests
// The API endpoints are defined in the openapi.yaml file
func listenApiRequests() {
err := http.ListenAndServe(":"+common.Getenv("API_SERVER_PORT", "3000"), apiserver.NewRouter(
apiserver.NewAssetMappingApiController(apiservices.NewAssetMappingApiService()),
apiserver.NewConfigurationApiController(apiservices.NewConfigurationApiService()),
apiserver.NewCustomizationApiController(apiservices.NewCustomizationApiService()),
apiserver.NewVersionApiController(apiservices.NewVersionApiService()),
))
err := http.ListenAndServe(":"+common.Getenv("API_SERVER_PORT", "3000"), utilshttp.NewCORSEnabledHandler(
apiserver.NewRouter(
apiserver.NewAssetMappingApiController(apiservices.NewAssetMappingApiService()),
apiserver.NewConfigurationApiController(apiservices.NewConfigurationApiService()),
apiserver.NewCustomizationApiController(apiservices.NewCustomizationApiService()),
apiserver.NewVersionApiController(apiservices.NewVersionApiService()),
)))
log.Fatal("Hailo", "Error in API Server: %v", err)
}

Expand Down
2 changes: 1 addition & 1 deletion eliona/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func upsertData(subtype api.DataSubtype, time time.Time, assetId int32, payload
statusData.Timestamp = *api.NewNullableTime(&time)
statusData.AssetId = assetId
statusData.Data = common.StructToMap(payload)
err := asset.UpsertDataIfAssetExists[any](statusData)
err := asset.UpsertDataIfAssetExists(statusData)
if err != nil {
log.Error("Hailo", "Error during writing data: %v", err)
return err
Expand Down
37 changes: 19 additions & 18 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,39 @@ module hailo
go 1.18

require (
github.com/eliona-smart-building-assistant/go-eliona v1.9.6
github.com/eliona-smart-building-assistant/go-eliona-api-client/v2 v2.4.14
github.com/eliona-smart-building-assistant/go-utils v1.0.21
github.com/eliona-smart-building-assistant/app-integration-tests v0.0.5
github.com/eliona-smart-building-assistant/go-eliona v1.9.9
github.com/eliona-smart-building-assistant/go-eliona-api-client/v2 v2.4.20
github.com/eliona-smart-building-assistant/go-utils v1.0.30
github.com/friendsofgo/errors v0.9.2
github.com/gorilla/mux v1.8.0
github.com/stretchr/testify v1.8.0
github.com/stretchr/testify v1.8.4
github.com/volatiletech/null/v8 v8.1.2
github.com/volatiletech/sqlboiler/v4 v4.13.0
github.com/volatiletech/sqlboiler/v4 v4.14.2
github.com/volatiletech/strmangle v0.0.4
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/ericlagergren/decimal v0.0.0-20181231230500-73749d4874d5 // indirect
github.com/gofrs/uuid v4.0.0+incompatible // indirect
github.com/ericlagergren/decimal v0.0.0-20211103172832-aca2edc11f73 // indirect
github.com/gofrs/uuid v4.2.0+incompatible // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgconn v1.12.1 // indirect
github.com/jackc/pgconn v1.14.0 // indirect
github.com/jackc/pgio v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgproto3/v2 v2.3.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect
github.com/jackc/pgtype v1.11.0 // indirect
github.com/jackc/pgx/v4 v4.16.1 // indirect
github.com/jackc/puddle v1.2.2-0.20220404125616-4e959849469a // indirect
github.com/lib/pq v1.10.2 // indirect
github.com/jackc/pgproto3/v2 v2.3.2 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/pgtype v1.14.0 // indirect
github.com/jackc/pgx/v4 v4.18.1 // indirect
github.com/jackc/puddle v1.3.0 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/cast v1.4.1 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/volatiletech/inflect v0.0.1 // indirect
github.com/volatiletech/randomize v0.0.1 // indirect
golang.org/x/crypto v0.0.0-20220214200702-86341886e292 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
golang.org/x/crypto v0.10.0 // indirect
golang.org/x/text v0.10.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 20fa297

Please sign in to comment.