Create a testing package for common utilities
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
a2cd015533
commit
b4ac128673
5 changed files with 11 additions and 10 deletions
4
Makefile
4
Makefile
|
|
@ -5,8 +5,6 @@ IMAGE_TAG = garm-build
|
||||||
USER_ID=$(shell ((docker --version | grep -q podman) && echo "0" || id -u))
|
USER_ID=$(shell ((docker --version | grep -q podman) && echo "0" || id -u))
|
||||||
USER_GROUP=$(shell ((docker --version | grep -q podman) && echo "0" || id -g))
|
USER_GROUP=$(shell ((docker --version | grep -q podman) && echo "0" || id -g))
|
||||||
|
|
||||||
GO_PACKAGES?=$(shell (go list ./... | grep -v 'vendor'))
|
|
||||||
|
|
||||||
default: build-static
|
default: build-static
|
||||||
|
|
||||||
.PHONY : build-static
|
.PHONY : build-static
|
||||||
|
|
@ -18,4 +16,4 @@ build-static:
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test:
|
test:
|
||||||
go test $(GO_PACKAGES) -v $(TEST_ARGS) -timeout=15m -parallel=4
|
go test -mod=vendor -tags testing -v $(TEST_ARGS) -timeout=15m -parallel=4 ./...
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
dbCommon "garm/database/common"
|
dbCommon "garm/database/common"
|
||||||
runnerErrors "garm/errors"
|
runnerErrors "garm/errors"
|
||||||
"garm/util"
|
garmTesting "garm/internal/testing"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
@ -31,7 +31,7 @@ type CtrlTestSuite struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *CtrlTestSuite) SetupTest() {
|
func (s *CtrlTestSuite) SetupTest() {
|
||||||
db, err := NewSQLDatabase(context.Background(), util.GetTestSqliteDBConfig(s.T()))
|
db, err := NewSQLDatabase(context.Background(), garmTesting.GetTestSqliteDBConfig(s.T()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.FailNow(fmt.Sprintf("failed to create db connection: %s", err))
|
s.FailNow(fmt.Sprintf("failed to create db connection: %s", err))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,10 @@
|
||||||
// License for the specific language governing permissions and limitations
|
// License for the specific language governing permissions and limitations
|
||||||
// under the License.
|
// under the License.
|
||||||
|
|
||||||
package util
|
//go:build testing
|
||||||
|
// +build testing
|
||||||
|
|
||||||
|
package testing
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"garm/config"
|
"garm/config"
|
||||||
|
|
@ -22,11 +22,11 @@ import (
|
||||||
"garm/database"
|
"garm/database"
|
||||||
dbCommon "garm/database/common"
|
dbCommon "garm/database/common"
|
||||||
runnerErrors "garm/errors"
|
runnerErrors "garm/errors"
|
||||||
|
garmTesting "garm/internal/testing"
|
||||||
"garm/params"
|
"garm/params"
|
||||||
"garm/runner/common"
|
"garm/runner/common"
|
||||||
runnerCommonMocks "garm/runner/common/mocks"
|
runnerCommonMocks "garm/runner/common/mocks"
|
||||||
runnerMocks "garm/runner/mocks"
|
runnerMocks "garm/runner/mocks"
|
||||||
"garm/util"
|
|
||||||
"sort"
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
|
@ -104,7 +104,7 @@ func (s *OrgTestSuite) SetupTest() {
|
||||||
adminCtx := auth.GetAdminContext()
|
adminCtx := auth.GetAdminContext()
|
||||||
|
|
||||||
// create testing sqlite database
|
// create testing sqlite database
|
||||||
dbCfg := util.GetTestSqliteDBConfig(s.T())
|
dbCfg := garmTesting.GetTestSqliteDBConfig(s.T())
|
||||||
db, err := database.NewDatabase(adminCtx, dbCfg)
|
db, err := database.NewDatabase(adminCtx, dbCfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.FailNow(fmt.Sprintf("failed to create db connection: %s", err))
|
s.FailNow(fmt.Sprintf("failed to create db connection: %s", err))
|
||||||
|
|
|
||||||
|
|
@ -22,11 +22,11 @@ import (
|
||||||
"garm/database"
|
"garm/database"
|
||||||
dbCommon "garm/database/common"
|
dbCommon "garm/database/common"
|
||||||
runnerErrors "garm/errors"
|
runnerErrors "garm/errors"
|
||||||
|
garmTesting "garm/internal/testing"
|
||||||
"garm/params"
|
"garm/params"
|
||||||
"garm/runner/common"
|
"garm/runner/common"
|
||||||
runnerCommonMocks "garm/runner/common/mocks"
|
runnerCommonMocks "garm/runner/common/mocks"
|
||||||
runnerMocks "garm/runner/mocks"
|
runnerMocks "garm/runner/mocks"
|
||||||
"garm/util"
|
|
||||||
"sort"
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
|
@ -103,7 +103,7 @@ func (s *RepoTestSuite) SetupTest() {
|
||||||
adminCtx := auth.GetAdminContext()
|
adminCtx := auth.GetAdminContext()
|
||||||
|
|
||||||
// create testing sqlite database
|
// create testing sqlite database
|
||||||
dbCfg := util.GetTestSqliteDBConfig(s.T())
|
dbCfg := garmTesting.GetTestSqliteDBConfig(s.T())
|
||||||
db, err := database.NewDatabase(adminCtx, dbCfg)
|
db, err := database.NewDatabase(adminCtx, dbCfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.FailNow(fmt.Sprintf("failed to create db connection: %s", err))
|
s.FailNow(fmt.Sprintf("failed to create db connection: %s", err))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue