Skip to content

Commit

Permalink
test: add more unit tests to service
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoclair committed Sep 17, 2024
1 parent a3122c3 commit 9f9142c
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions application/service/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,34 @@ package service

import (
"testing"
"time"

infraMocks "github.com/diegoclair/go_boilerplate/infra/mocks"
"github.com/stretchr/testify/assert"
)

func TestNew(t *testing.T) {
t.Run("Valid infrastructure", func(t *testing.T) {
m, ctrl := newServiceTestMock(t)
defer ctrl.Finish()

apps, err := New(m.mockInfra, time.Hour)
assert.NoError(t, err)
assert.NotNil(t, apps)
})

t.Run("Invalid infrastructure", func(t *testing.T) {
m, ctrl := newServiceTestMock(t)
m.mockInfra = infraMocks.NewMockInfrastructure(ctrl)
m.mockInfra.EXPECT().Logger().Return(nil)
defer ctrl.Finish()

apps, err := New(m.mockInfra, time.Hour)
assert.Error(t, err)
assert.Nil(t, apps)
})
}

func TestValidateInfrastructure(t *testing.T) {
m, ctrl := newServiceTestMock(t)
defer ctrl.Finish()
Expand Down

0 comments on commit 9f9142c

Please sign in to comment.