You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
785 B
Go
36 lines
785 B
Go
package mock
|
|
|
|
import (
|
|
"database/sql"
|
|
"time"
|
|
|
|
"git.runcible.io/learning/ratchet/internal/model"
|
|
)
|
|
|
|
var mockSnippet = model.Snippet{
|
|
ID: 1,
|
|
Title: sql.NullString{String: "Hello golang mocking", Valid: true},
|
|
Content: sql.NullString{String: "Hello golang mocking", Valid: true},
|
|
CreatedAt: time.Now(),
|
|
UpdatedAt: time.Now(),
|
|
ExpiresAt: time.Now(),
|
|
}
|
|
|
|
type SnippetService struct{}
|
|
|
|
func (s *SnippetService) Insert(title, content string, expiresAt int) (int, error) {
|
|
return 2, nil
|
|
}
|
|
|
|
func (s *SnippetService) Get(id int) (model.Snippet, error) {
|
|
if id == mockSnippet.ID {
|
|
return mockSnippet, nil
|
|
} else {
|
|
return model.Snippet{}, model.ErrNoRecord
|
|
}
|
|
}
|
|
|
|
func (s *SnippetService) Lastest() ([]model.Snippet, error) {
|
|
return []model.Snippet{mockSnippet}, nil
|
|
}
|