Skip to content

Commit

Permalink
NOISSUE - Add Dashboard Respository Tests (#234)
Browse files Browse the repository at this point in the history
* test(ui): add postgres dashboard respository tests

Signed-off-by: Rodney Osodo <[email protected]>

* fix(ui): fix dbconfig env var parsing

* add non empty check rather than using pointers

Signed-off-by: Rodney Osodo <[email protected]>

* remove unnecessary tests

Signed-off-by: Rodney Osodo <[email protected]>

---------

Signed-off-by: Rodney Osodo <[email protected]>
  • Loading branch information
rodneyosodo authored Mar 14, 2024
1 parent df7889e commit 0bb1df1
Show file tree
Hide file tree
Showing 11 changed files with 861 additions and 48 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,12 @@ jobs:
- name: Run Tests
run: |
go mod vendor
make test
- name: Upload coverage
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV }}
file: ./coverage.out
name: codecov-umbrella
verbose: true
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ install:
cp ${BUILD_DIR}/$(SVC) $(GOBIN)/magistrala-${SVC}

test:
go test -v -race -count 1 -tags test $(shell go list ./... | grep -v 'cmd')
go test -v -race -count 1 -tags test -coverprofile=coverage.out $(shell go list ./... | grep -v 'cmd')

lint:
golangci-lint run --config .golangci.yml
Expand Down
5 changes: 4 additions & 1 deletion cmd/ui/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,15 @@ func main() {
oauthProvider := google.NewProvider(oauthConfig)

dbConfig := postgres.Config{}
if err := env.Parse(&dbConfig); err != nil {
log.Fatalf("failed to load database configuration : %s", err.Error())
}
db, err := postgres.Setup(dbConfig, *repo.Migration())
if err != nil {
log.Fatalf("Failed to setup postgres db : %s", err)
}

dbs := repo.New(db)
dbs := repo.NewRepository(db)

idp := uuid.New()

Expand Down
42 changes: 36 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,23 @@ module github.com/absmach/magistrala-ui
go 1.21.5

require (
github.com/0x6flab/namegenerator v1.2.0
github.com/absmach/agent v0.0.0-20240202075640-cc619e6685c8
github.com/absmach/magistrala v0.14.1-0.20240305111255-42d433a92f39
github.com/absmach/senml v1.0.5
github.com/caarlos0/env/v10 v10.0.0
github.com/eclipse/paho.mqtt.golang v1.4.3
github.com/go-chi/chi/v5 v5.0.12
github.com/go-gorp/gorp/v3 v3.1.0 // indirect
github.com/go-kit/kit v0.13.0
github.com/go-zoo/bone v1.3.0
github.com/golang-jwt/jwt v3.2.2+incompatible
github.com/gorilla/securecookie v1.1.2
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 // indirect
github.com/jackc/pgx/v5 v5.5.5
github.com/jackc/puddle/v2 v2.2.1 // indirect
github.com/jmoiron/sqlx v1.3.5
github.com/pkg/errors v0.9.1
github.com/ory/dockertest/v3 v3.10.0
github.com/prometheus/client_golang v1.19.0
github.com/rubenv/sql-migrate v1.6.1
golang.org/x/crypto v0.21.0 // indirect
github.com/stretchr/testify v1.8.4
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225
golang.org/x/oauth2 v0.18.0
golang.org/x/sync v0.6.0
Expand All @@ -32,28 +29,61 @@ require (
require (
cloud.google.com/go/compute v1.23.3 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/containerd/continuity v0.4.3 // indirect
github.com/creack/pty v1.1.18 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/docker/cli v24.0.7+incompatible // indirect
github.com/docker/docker v24.0.7+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/edgexfoundry/go-mod-core-contracts v0.1.70 // indirect
github.com/fxamacker/cbor/v2 v2.5.0 // indirect
github.com/go-gorp/gorp/v3 v3.1.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/gofrs/uuid v4.4.0+incompatible // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/websocket v1.5.1 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 // indirect
github.com/jackc/puddle/v2 v2.2.1 // indirect
github.com/mainflux/export v0.1.1-0.20230724124847-67d0bc7f38cb // indirect
github.com/mainflux/mainflux v0.12.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.2 // indirect
github.com/opencontainers/runc v1.1.12 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.48.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/mod v0.15.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.18.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/protobuf v1.32.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 0bb1df1

Please sign in to comment.