features/module-name #14
@ -3,7 +3,8 @@ package repositories
|
|||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"errors"
|
"errors"
|
||||||
"go-cook/api/domain"
|
|
||||||
|
"git.jamestombleson.com/jtom38/go-cook/api/domain"
|
||||||
)
|
)
|
||||||
|
|
||||||
type IRecipeTable interface {
|
type IRecipeTable interface {
|
||||||
@ -11,7 +12,7 @@ type IRecipeTable interface {
|
|||||||
List() ([]domain.RecipeEntity, error)
|
List() ([]domain.RecipeEntity, error)
|
||||||
Get(id int) (domain.RecipeEntity, error)
|
Get(id int) (domain.RecipeEntity, error)
|
||||||
Update(id int, entity domain.RecipeEntity) error
|
Update(id int, entity domain.RecipeEntity) error
|
||||||
Delete(id int) error
|
Delete(id int) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type RecipeRepository struct {
|
type RecipeRepository struct {
|
||||||
|
@ -4,9 +4,10 @@ import (
|
|||||||
"database/sql"
|
"database/sql"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"go-cook/api/domain"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"git.jamestombleson.com/jtom38/go-cook/api/domain"
|
||||||
|
|
||||||
"github.com/huandu/go-sqlbuilder"
|
"github.com/huandu/go-sqlbuilder"
|
||||||
"golang.org/x/crypto/bcrypt"
|
"golang.org/x/crypto/bcrypt"
|
||||||
)
|
)
|
||||||
@ -113,7 +114,7 @@ func (ur UserRepository) CheckUserHash(name, password string) error {
|
|||||||
func (ur UserRepository) UpdateScopes(name, scope string) error {
|
func (ur UserRepository) UpdateScopes(name, scope string) error {
|
||||||
builder := sqlbuilder.NewUpdateBuilder()
|
builder := sqlbuilder.NewUpdateBuilder()
|
||||||
builder.Update("users")
|
builder.Update("users")
|
||||||
builder.Set (
|
builder.Set(
|
||||||
builder.Assign("Scopes", scope),
|
builder.Assign("Scopes", scope),
|
||||||
)
|
)
|
||||||
builder.Where(
|
builder.Where(
|
||||||
|
@ -2,11 +2,12 @@ package repositories_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"go-cook/api/domain"
|
|
||||||
"go-cook/api/repositories"
|
|
||||||
"log"
|
"log"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"git.jamestombleson.com/jtom38/go-cook/api/repositories"
|
||||||
|
"git.jamestombleson.com/jtom38/go-cook/api/domain"
|
||||||
|
|
||||||
"github.com/DATA-DOG/go-sqlmock"
|
"github.com/DATA-DOG/go-sqlmock"
|
||||||
_ "github.com/glebarez/go-sqlite"
|
_ "github.com/glebarez/go-sqlite"
|
||||||
)
|
)
|
||||||
@ -46,7 +47,7 @@ func TestCanFindUserInTable(t *testing.T) {
|
|||||||
log.Println(user)
|
log.Println(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCheckUserHash (t *testing.T) {
|
func TestCheckUserHash(t *testing.T) {
|
||||||
db, err := sql.Open("sqlite", "../../gocook.db")
|
db, err := sql.Open("sqlite", "../../gocook.db")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("unable to open connection")
|
log.Println("unable to open connection")
|
||||||
@ -56,4 +57,4 @@ func TestCheckUserHash (t *testing.T) {
|
|||||||
|
|
||||||
repo := repositories.NewUserRepository(db)
|
repo := repositories.NewUserRepository(db)
|
||||||
repo.CheckUserHash("testing", "NotSecure")
|
repo.CheckUserHash("testing", "NotSecure")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user