Refactor id generator to it's own package

This commit is contained in:
Jonathan Leibiusky @xetorthio
2017-09-14 10:20:20 -03:00
parent 3ca50eae2e
commit 86a0f7d1e9
9 changed files with 64 additions and 60 deletions

5
id/generator.go Normal file
View File

@@ -0,0 +1,5 @@
package id
type Generator interface {
NewId() string
}

12
id/mock.go Normal file
View File

@@ -0,0 +1,12 @@
package id
import "github.com/stretchr/testify/mock"
type MockGenerator struct {
mock.Mock
}
func (m *MockGenerator) NewId() string {
args := m.Called()
return args.String(0)
}

10
id/xid.go Normal file
View File

@@ -0,0 +1,10 @@
package id
import "github.com/rs/xid"
type XIDGenerator struct {
}
func (x XIDGenerator) NewId() string {
return xid.New().String()
}