Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| add66f7268 | |||
| 0e64561a0b | |||
| dd7462897e | |||
| 8fab5ff4b7 | |||
| c659ddd2f9 | |||
| 47c83d1a02 | |||
| 7f85b25a31 | |||
| b144473111 | |||
| fff864a741 | |||
| 7642d7e9c1 | |||
| 359692e6ea | |||
| 3a53016092 | |||
| 30ee12f789 | |||
| 56f1273747 | |||
| d5e322ca9e | |||
| 18d12ed1b4 |
+3
-3
@@ -20,7 +20,7 @@
|
|||||||
include:
|
include:
|
||||||
- template: 'Workflows/MergeRequest-Pipelines.gitlab-ci.yml'
|
- template: 'Workflows/MergeRequest-Pipelines.gitlab-ci.yml'
|
||||||
|
|
||||||
image: golang:1.15
|
image: golang:1.22
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
GOFLAGS: -mod=readonly
|
GOFLAGS: -mod=readonly
|
||||||
@@ -39,10 +39,10 @@ test:
|
|||||||
dependencies:
|
dependencies:
|
||||||
- deps
|
- deps
|
||||||
script:
|
script:
|
||||||
- go get golang.org/x/lint/golint
|
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.56.2
|
||||||
- go fmt $(go list ./...)
|
- go fmt $(go list ./...)
|
||||||
- go vet $(go list ./...)
|
- go vet $(go list ./...)
|
||||||
- golint -set_exit_status ./...
|
- golangci-lint run
|
||||||
- CGO_ENABLED=1 go test -mod=readonly -race -coverprofile=coverage.txt -covermode=atomic -coverpkg=$(go list ./... | tr '\n' , | sed 's/,$//') ./...
|
- CGO_ENABLED=1 go test -mod=readonly -race -coverprofile=coverage.txt -covermode=atomic -coverpkg=$(go list ./... | tr '\n' , | sed 's/,$//') ./...
|
||||||
- go tool cover -html=coverage.txt -o coverage.html
|
- go tool cover -html=coverage.txt -o coverage.html
|
||||||
- go tool cover -func=coverage.txt
|
- go tool cover -func=coverage.txt
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
# To get started with Dependabot version updates, you'll need to specify which
|
|
||||||
# package ecosystems to update and where the package manifests are located.
|
|
||||||
# Please see the documentation for all configuration options:
|
|
||||||
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
|
||||||
|
|
||||||
version: 2
|
|
||||||
updates:
|
|
||||||
- package-ecosystem: "gomod"
|
|
||||||
directory: "/"
|
|
||||||
schedule:
|
|
||||||
interval: "daily"
|
|
||||||
open-pull-requests-limit: 20
|
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
run:
|
||||||
|
allow-parallel-runners: true
|
||||||
@@ -1,8 +1,15 @@
|
|||||||
module gitlab.com/unboundsoftware/apex-mocks
|
module gitlab.com/unboundsoftware/apex-mocks
|
||||||
|
|
||||||
go 1.15
|
go 1.20
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/apex/log v1.9.0
|
github.com/apex/log v1.9.0
|
||||||
github.com/stretchr/testify v1.6.1
|
github.com/stretchr/testify v1.9.0
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
|
github.com/pkg/errors v0.8.1 // indirect
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -41,8 +41,9 @@ github.com/smartystreets/go-aws-auth v0.0.0-20180515143844-0c1422d1fdb9/go.mod h
|
|||||||
github.com/smartystreets/gunit v1.0.0/go.mod h1:qwPWnhz6pn0NnRBP++URONOVyNkPyr4SauJk4cUOwJs=
|
github.com/smartystreets/gunit v1.0.0/go.mod h1:qwPWnhz6pn0NnRBP++URONOVyNkPyr4SauJk4cUOwJs=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
|
|
||||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||||
|
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
github.com/tj/assert v0.0.0-20171129193455-018094318fb0/go.mod h1:mZ9/Rh9oLWpLLDRpvE+3b7gP/C2YyLFYxNmcLnPTMe0=
|
github.com/tj/assert v0.0.0-20171129193455-018094318fb0/go.mod h1:mZ9/Rh9oLWpLLDRpvE+3b7gP/C2YyLFYxNmcLnPTMe0=
|
||||||
github.com/tj/assert v0.0.3 h1:Df/BlaZ20mq6kuai7f5z2TvPFiwC3xaWJSDQNiIS3Rk=
|
github.com/tj/assert v0.0.3 h1:Df/BlaZ20mq6kuai7f5z2TvPFiwC3xaWJSDQNiIS3Rk=
|
||||||
github.com/tj/assert v0.0.3/go.mod h1:Ne6X72Q+TB1AteidzQncjw9PabbMp4PBMZ1k+vd1Pvk=
|
github.com/tj/assert v0.0.3/go.mod h1:Ne6X72Q+TB1AteidzQncjw9PabbMp4PBMZ1k+vd1Pvk=
|
||||||
@@ -71,5 +72,6 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD
|
|||||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c h1:grhR+C34yXImVGp7EzNk+DTIk+323eIUWOmEevy6bDo=
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import (
|
|||||||
// Mock has a Logger for use in unit-testing
|
// Mock has a Logger for use in unit-testing
|
||||||
type Mock struct {
|
type Mock struct {
|
||||||
*sync.RWMutex
|
*sync.RWMutex
|
||||||
Logger log.Interface
|
log.Interface
|
||||||
Logged []string
|
Logged []string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,8 +48,9 @@ var _ log.Handler = &Mock{}
|
|||||||
// New instantiates a new Mock and sets the log.Handler to it
|
// New instantiates a new Mock and sets the log.Handler to it
|
||||||
func New() *Mock {
|
func New() *Mock {
|
||||||
mock := &Mock{
|
mock := &Mock{
|
||||||
RWMutex: &sync.RWMutex{},
|
RWMutex: &sync.RWMutex{},
|
||||||
Logger: log.Log,
|
Interface: log.Log,
|
||||||
|
Logged: make([]string, 0),
|
||||||
}
|
}
|
||||||
log.SetHandler(mock)
|
log.SetHandler(mock)
|
||||||
return mock
|
return mock
|
||||||
@@ -60,5 +61,8 @@ func (m *Mock) Check(t testing.TB, wantLogged []string) {
|
|||||||
t.Helper()
|
t.Helper()
|
||||||
m.RLock()
|
m.RLock()
|
||||||
defer m.RUnlock()
|
defer m.RUnlock()
|
||||||
|
if wantLogged == nil {
|
||||||
|
wantLogged = []string{}
|
||||||
|
}
|
||||||
assert.Equal(t, wantLogged, m.Logged)
|
assert.Equal(t, wantLogged, m.Logged)
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-2
@@ -21,6 +21,7 @@ package apex
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"regexp"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@@ -50,7 +51,7 @@ func TestMock_Check(t *testing.T) {
|
|||||||
name: "different",
|
name: "different",
|
||||||
fields: fields{Logged: []string{"same"}},
|
fields: fields{Logged: []string{"same"}},
|
||||||
args: args{wantLogged: []string{"different"}},
|
args: args{wantLogged: []string{"different"}},
|
||||||
want: []string{"\n\tError Trace:\tmocks.go:63\n\t \t\t\t\tmocks_test.go:63\n\tError: \tNot equal: \n\t \texpected: []string{\"different\"}\n\t \tactual : []string{\"same\"}\n\t \t\n\t \tDiff:\n\t \t--- Expected\n\t \t+++ Actual\n\t \t@@ -1,3 +1,3 @@\n\t \t ([]string) (len=1) {\n\t \t- (string) (len=9) \"different\"\n\t \t+ (string) (len=4) \"same\"\n\t \t }\n\tTest: \t\n"},
|
want: []string{"\n\tError: \tNot equal: \n\t \texpected: []string{\"different\"}\n\t \tactual : []string{\"same\"}\n\t \t\n\t \tDiff:\n\t \t--- Expected\n\t \t+++ Actual\n\t \t@@ -1,3 +1,3 @@\n\t \t ([]string) (len=1) {\n\t \t- (string) (len=9) \"different\"\n\t \t+ (string) (len=4) \"same\"\n\t \t }\n\tTest: \t\n"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
@@ -68,7 +69,7 @@ func TestMock_Check(t *testing.T) {
|
|||||||
|
|
||||||
func TestNew(t *testing.T) {
|
func TestNew(t *testing.T) {
|
||||||
logger := New()
|
logger := New()
|
||||||
logger.Logger.Info("logging")
|
logger.Info("logging")
|
||||||
logger.Check(t, []string{"info: logging"})
|
logger.Check(t, []string{"info: logging"})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,5 +79,12 @@ type MockT struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *MockT) Errorf(format string, args ...interface{}) {
|
func (m *MockT) Errorf(format string, args ...interface{}) {
|
||||||
|
re, err := regexp.Compile(`(?s)^\tError Trace:.*(\tError:.*)$`)
|
||||||
|
assert.NoError(m, err)
|
||||||
|
for i, a := range args {
|
||||||
|
if s, ok := a.(string); ok {
|
||||||
|
args[i] = re.ReplaceAllString(s, "$1")
|
||||||
|
}
|
||||||
|
}
|
||||||
m.errors = append(m.errors, fmt.Sprintf(format, args...))
|
m.errors = append(m.errors, fmt.Sprintf(format, args...))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||||
|
"extends": [
|
||||||
|
"config:recommended"
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user