Commit graph

144 commits

Author SHA1 Message Date
Gabriel
e9e6e507a4
Merge pull request #34 from mihaelabalutoiu/add-db-organizations-unit-tests
Add `organizations.go` database unit testing
2022-10-12 19:18:42 +03:00
Mihaela Balutoiu
8d138afde2 Add organizations.go database unit testing
Add more test cases regarding the SQL database interactions.

Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2022-10-12 17:27:08 +03:00
Gabriel
e82c97bbc6
Merge pull request #31 from mihaelabalutoiu/fix-error-wrap
Fixed error wrap
2022-10-10 14:52:16 +03:00
Mihaela Balutoiu
1116de7608 Fixed error wrap
The error is not wrapped correctly, because instead of using `q.Error`,
it uses `err`, which is defined elsewhere.

Also, the `UpdateOrganization` and `CreateOrganizationPool` functions will
never fail on update/create org, because it returns a nil error, instead
of wrap error.

Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2022-10-10 14:45:55 +03:00
Gabriel
59c8f397ac
Merge pull request #28 from mercedes-benz/no-404
feat: webhook does not return error on 'instance not found'.
2022-10-07 12:27:47 +03:00
Michael Kuhnt
5bfecbaa30 feat: webhook does not return error on 'instance not found'.
This case is probably caused by a webhook event that was meant for
another runner controller / manager. No need to report this as
error, we can simply ignore this and avoid noise in the logs.
2022-10-07 11:18:25 +02:00
Gabriel
e0d1de69e4
Merge pull request #27 from mihaelabalutoiu/add-db-organizations-unit-tests
Add more `organizations.go` unit testing
2022-10-06 13:40:05 +03:00
Mihaela Balutoiu
23f521b682 Add more organizations.go unit testing 2022-10-06 11:59:05 +03:00
Gabriel
e83f06529a
Merge pull request #26 from gabriel-samfira/make-queries-case-insensitive
Make owners and repos case insensitive
2022-10-06 11:26:17 +03:00
Gabriel Adrian Samfira
0ff2fd2e06
Make owners and repos case insensitive
Github treats owners (users and orgs) and repos as case insensitive. To
github, https://github.com/cloudbase/garm is equivalent to
https://github.com/CloudBase/GaRm. This commit makes the sql store
backend, case insensitive when querying repos and orgs.

Fixes: #25

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-10-05 18:14:07 +03:00
Gabriel
8ca9a82529
Merge pull request #24 from mihaelabalutoiu/add-db-organizations-unit-tests
Add `organizations.go` unit tests
2022-10-05 16:17:14 +03:00
Mihaela Balutoiu
5692439dda Add organizations.go unit tests 2022-10-03 17:55:35 +03:00
Gabriel
e9aba82ec1
Merge pull request #23 from mihaelabalutoiu/add-db-instances-unit-tests
Add `instances.go` database unit tests
2022-09-28 18:01:39 +03:00
Mihaela Balutoiu
723c9c3d60 Add instances.go database unit tests
Add more test cases regarding the SQL database interactions.
Moreover, add `go-sqlmock` dependency used to mock SQL DB instructions.

Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2022-09-28 17:29:40 +03:00
Gabriel
3c49df5144
Merge pull request #22 from mihaelabalutoiu/add-db-instances-unit-tests
Add more `instances.go` unit tests
2022-09-21 20:37:29 +03:00
Mihaela Balutoiu
898e098ff8 Add more instances.go unit tests
Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2022-09-21 20:34:14 +03:00
Gabriel
d9332f21ae
Merge pull request #21 from ionutbalutoiu/add-badge-link
Add link to `Go Tests` README badge
2022-09-21 18:40:16 +03:00
Ionut Balutoiu
b8e6d56428 Add link to Go Tests README badge
Make sure that the README `Go Test` badge has a link to the GitHub
page with latest workflow results.

Signed-off-by: Ionut Balutoiu <ibalutoiu@cloudbasesolutions.com>
2022-09-21 18:26:43 +03:00
Gabriel
93619b8d4e
Merge pull request #19 from gabriel-samfira/fetch-runner-name-from-api
Attempt to fetch runner name from API
2022-09-20 16:50:13 +03:00
Gabriel Adrian Samfira
e8fa6dba6e
Attempt to fetch runner name from API
In some cases, runner information is not sent via webhook by Github when
a workflow job transitions to in_progress. We need to know the runner
name in order to update the state in the database. Attempt to fetch the
runner from the API using the workflow ID.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-09-20 14:46:44 +03:00
Gabriel
8cec645b10
Merge pull request #18 from mihaelabalutoiu/cleanup-unused-struct-field
Cleanup unused struct field and Fix typo
2022-09-16 15:02:39 +03:00
mihaelabalutoiu
6039a97d5a Fix typo 2022-09-15 19:18:28 +03:00
mihaelabalutoiu
e2ada6d1e3 Cleanup unused struct field
Remove `Pool` field from `CreateInstanceParams` struct, because
this is given as a separate parameter to the `CreateInstance` function.
2022-09-15 19:11:37 +03:00
Gabriel
775dd51782
Merge pull request #16 from mihaelabalutoiu/add-db-instances-unit-tests
Add `instances.go` unit tests
2022-09-15 19:01:13 +03:00
mihaelabalutoiu
797ec21dd9 Add instances.go unit tests 2022-09-15 18:59:16 +03:00
Gabriel
476c3b814f
Merge pull request #17 from gabriel-samfira/create-testing-package
Create a testing package for common utilities
2022-09-15 18:03:06 +03:00
Gabriel Adrian Samfira
b4ac128673
Create a testing package for common utilities
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-09-15 17:48:09 +03:00
Gabriel
a2cd015533
Merge pull request #15 from mihaelabalutoiu/cleanup-duplicate-code
Cleanup duplicate code
2022-09-14 15:55:23 +03:00
mihaelabalutoiu
8c910d904f Cleanup duplicate code 2022-09-14 12:55:26 +03:00
Gabriel
777c41e411
Merge pull request #14 from mihaelabalutoiu/add-db-ctrl-unit-tests
Add `controller.go` unit tests
2022-09-13 15:23:50 +03:00
mihaelabalutoiu
6fe6680e52 Fix database.go typo 2022-09-13 15:01:17 +03:00
mihaelabalutoiu
bdb087578a Add controller.go unit tests 2022-09-13 14:21:21 +03:00
Gabriel
5759b74e0d
Merge pull request #12 from mihaelabalutoiu/add-repositories-unit-tests
Add `repositories.go` unit tests
2022-09-09 17:51:11 +03:00
Gabriel
8b1c8860a0
Merge pull request #13 from mihaelabalutoiu/update-organizations-unit-tests
Update `organizations.go` unit tests
2022-09-09 17:50:05 +03:00
mihaelabalutoiu
8215edfe26 Update organization.go unit tests 2022-09-09 16:38:52 +03:00
mihaelabalutoiu
54f2dd6154 Add repositories.go unit tests 2022-09-09 15:57:18 +03:00
Gabriel
8e3b1e508c
Merge pull request #11 from mihaelabalutoiu/add-repositories-unit-tests
Add more `repositories.go` unit testing
2022-09-09 11:33:20 +03:00
mihaelabalutoiu
c5158fbf5c Add more repositories.go unit testing 2022-09-09 10:47:36 +03:00
Gabriel
16a81cfd1b
Merge pull request #10 from mihaelabalutoiu/add-repositories-unit-tests
Add `repositories.go` unit tests
2022-09-07 18:25:27 +03:00
mihaelabalutoiu
505489eddf Add repositories.go unit tests 2022-09-07 16:49:42 +03:00
Gabriel
2ccfbc480b
Merge pull request #9 from ionutbalutoiu/add-go-tests-github-workflow
Add go tests GitHub workflow
2022-09-07 16:36:28 +03:00
Ionut Balutoiu
30c1510967 Add Go Tests GitHub workflow
Signed-off-by: Ionut Balutoiu <ibalutoiu@cloudbasesolutions.com>
2022-09-07 16:33:13 +03:00
Ionut Balutoiu
8f29f90488 Add 'go test' Makefile target
Signed-off-by: Ionut Balutoiu <ibalutoiu@cloudbasesolutions.com>
2022-09-07 16:32:29 +03:00
Gabriel Adrian Samfira
3949912678
Update gitignore
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-09-06 21:36:35 +03:00
Gabriel Adrian Samfira
d4b7fca9f6
Fix test config_dir
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-09-06 21:35:42 +03:00
Gabriel Adrian Samfira
99856af4de
Silence gorm default logger
Disable the default logger for gorm when debug is not set on the sql
store backend. By default gorm will print error level log messages,
which includes queries which find no results, which is not really an
error.

These messages will show up if debug is enabled on the sql store
backend.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-09-06 21:35:01 +03:00
Gabriel
c0df364bb0
Merge pull request #8 from mihaelabalutoiu/add-organizations-unit-tests
Add `organizations.go` unit tests and `PoolManagerController` mocks
2022-09-06 20:12:46 +03:00
mihaelabalutoiu
1a7c31c8ea Add more organizations.go unit testing
Also, update vendor with the `github.com/stretchr/testify/suite`.
2022-09-06 18:04:51 +03:00
mihaelabalutoiu
3094ad09be Add PoolManagerController mocks 2022-09-01 16:08:56 +03:00
Gabriel
b74b829ce6
Merge pull request #7 from mihaelabalutoiu/refactor-code
Refactor code to allow more unit testing
2022-08-19 13:07:12 +03:00