Skip to content

Commit

Permalink
Merge pull request #183 from mocktools/develop
Browse files Browse the repository at this point in the history
Golang smtpmock v2.3.1
  • Loading branch information
bestwebua authored Aug 4, 2024
2 parents 278329c + 23d64a3 commit 1b8e678
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ version: 2.1
defaults: &defaults
working_directory: ~/go-smtp-mock
docker:
- image: cimg/go:1.21.5
- image: cimg/go:1.22.5

jobs:
linters:
docker:
- image: golangci/golangci-lint:v1.55.2-alpine
- image: golangci/golangci-lint:v1.56.2-alpine

steps:
- checkout
Expand Down
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
golang 1.22.0
golang 1.22.5
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.3.1] - 2024-08-04

### Updated

- Updated development dependencies
- Updated `circleci` config

## [2.3.0] - 2024-03-03

### Added
Expand Down
4 changes: 2 additions & 2 deletions cmd/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import (
)

func TestMain(t *testing.T) {
t.Run("when error not happened", func(t *testing.T) {
t.Run("when error not happened", func(*testing.T) {
os.Args = []string{os.Args[0]}
signals <- syscall.SIGINT
main()
})

t.Run("when error happened", func(t *testing.T) {
t.Run("when error happened", func(*testing.T) {
defer func() { logFatalf = log.Fatalf }()
os.Args = []string{os.Args[0], "-host=a"}
logMock := new(logMock)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module github.com/mocktools/go-smtp-mock/v2

go 1.15

require github.com/stretchr/testify v1.8.0
require github.com/stretchr/testify v1.9.0
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
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=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Expand Down
2 changes: 1 addition & 1 deletion handler_data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func TestHandlerDataClearMessage(t *testing.T) {
}

func TestHandlerDataProcessIncomingMessage(t *testing.T) {
t.Run("when successful request received", func(t *testing.T) {
t.Run("when successful request received", func(*testing.T) {
handlerMessage := &handlerMessageMock{}
handler := &handlerData{handlerMessage: handlerMessage}
handler.handlerMessage = handlerMessage
Expand Down
12 changes: 6 additions & 6 deletions server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func TestServerAddToWaitGroup(t *testing.T) {
waitGroup := new(waitGroupMock)
server := &Server{wg: waitGroup}

t.Run("increases count of goroutines by one", func(t *testing.T) {
t.Run("increases count of goroutines by one", func(*testing.T) {
waitGroup.On("Add", 1).Once().Return(nil)
server.addToWaitGroup()
})
Expand All @@ -284,7 +284,7 @@ func TestServerRemoveFromWaitGroup(t *testing.T) {
waitGroup := new(waitGroupMock)
server := &Server{wg: waitGroup}

t.Run("decreases count of goroutines by one", func(t *testing.T) {
t.Run("decreases count of goroutines by one", func(*testing.T) {
waitGroup.On("Done").Once().Return(nil)
server.removeFromWaitGroup()
})
Expand Down Expand Up @@ -473,7 +473,7 @@ func TestServerHandleSession(t *testing.T) {
assert.Equal(t, 2, len(server.Messages()))
})

t.Run("when invalid command, fail fast scenario disabled", func(t *testing.T) {
t.Run("when invalid command, fail fast scenario disabled", func(*testing.T) {
session, configuration := &sessionMock{}, createConfiguration()
server := newServer(configuration)

Expand All @@ -492,7 +492,7 @@ func TestServerHandleSession(t *testing.T) {
server.handleSession(session)
})

t.Run("when invalid command, session error, fail fast scenario enabled", func(t *testing.T) {
t.Run("when invalid command, session error, fail fast scenario enabled", func(*testing.T) {
session, configuration := &sessionMock{}, newConfiguration(ConfigurationAttr{IsCmdFailFast: true})
server, errorMessage := newServer(configuration), configuration.msgInvalidCmdHeloArg

Expand All @@ -514,7 +514,7 @@ func TestServerHandleSession(t *testing.T) {
server.handleSession(session)
})

t.Run("when server quit channel was closed", func(t *testing.T) {
t.Run("when server quit channel was closed", func(*testing.T) {
session, configuration := &sessionMock{}, newConfiguration(ConfigurationAttr{IsCmdFailFast: true})
server := newServer(configuration)
server.quit = make(chan interface{})
Expand All @@ -526,7 +526,7 @@ func TestServerHandleSession(t *testing.T) {
server.handleSession(session)
})

t.Run("when read request session error", func(t *testing.T) {
t.Run("when read request session error", func(*testing.T) {
session, configuration := &sessionMock{}, newConfiguration(ConfigurationAttr{IsCmdFailFast: true})
server := newServer(configuration)

Expand Down
4 changes: 2 additions & 2 deletions session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestSessionSetTimeout(t *testing.T) {
timeStub, timeout := time.Now(), 42
timeNow = func() time.Time { return timeStub }

t.Run("sets connection deadline for session", func(t *testing.T) {
t.Run("sets connection deadline for session", func(*testing.T) {
connection := netConnectionMock{}
connection.On("SetDeadline", timeNow().Add(time.Duration(timeout)*time.Second)).Once().Return(nil)
session := &session{connection: connection}
Expand All @@ -81,7 +81,7 @@ func TestSessionSetTimeout(t *testing.T) {
}

func TestSessionDiscardBufin(t *testing.T) {
t.Run("discardes the bufin remnants", func(t *testing.T) {
t.Run("discardes the bufin remnants", func(*testing.T) {
bufin := new(bufioReaderMock)
session := &session{bufin: bufin}
bufin.On("Buffered").Once().Return(42)
Expand Down

0 comments on commit 1b8e678

Please sign in to comment.