github.com/secure-build/gitlab-runner@v12.5.0+incompatible/helpers/service/simple_test.go (about)

     1  package service_helpers
     2  
     3  import (
     4  	"errors"
     5  	"testing"
     6  
     7  	"github.com/golang/mock/gomock"
     8  	"github.com/stretchr/testify/assert"
     9  
    10  	"gitlab.com/gitlab-org/gitlab-runner/helpers/service/mocks"
    11  )
    12  
    13  var errExample = errors.New("example error")
    14  
    15  func TestStart(t *testing.T) {
    16  	ctrl := gomock.NewController(t)
    17  	defer ctrl.Finish()
    18  
    19  	mi := &mocks.Interface{}
    20  	s := &SimpleService{i: mi}
    21  
    22  	mi.On("Start", s).Return(errExample)
    23  
    24  	err := s.Run()
    25  	assert.Equal(t, errExample, err)
    26  	mi.AssertExpectations(t)
    27  }