move models into db package
This commit is contained in:
@@ -4,11 +4,11 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"senan.xyz/g/gonic/model"
|
||||
"senan.xyz/g/gonic/db"
|
||||
)
|
||||
|
||||
type item struct {
|
||||
value *model.Album
|
||||
value *db.Album
|
||||
next *item
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ type Stack struct {
|
||||
len uint
|
||||
}
|
||||
|
||||
func (s *Stack) Push(v *model.Album) {
|
||||
func (s *Stack) Push(v *db.Album) {
|
||||
s.top = &item{
|
||||
value: v,
|
||||
next: s.top,
|
||||
@@ -25,7 +25,7 @@ func (s *Stack) Push(v *model.Album) {
|
||||
s.len++
|
||||
}
|
||||
|
||||
func (s *Stack) Pop() *model.Album {
|
||||
func (s *Stack) Pop() *db.Album {
|
||||
if s.len == 0 {
|
||||
return nil
|
||||
}
|
||||
@@ -35,7 +35,7 @@ func (s *Stack) Pop() *model.Album {
|
||||
return v
|
||||
}
|
||||
|
||||
func (s *Stack) Peek() *model.Album {
|
||||
func (s *Stack) Peek() *db.Album {
|
||||
if s.len == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -3,15 +3,15 @@ package stack
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"senan.xyz/g/gonic/model"
|
||||
"senan.xyz/g/gonic/db"
|
||||
)
|
||||
|
||||
func TestFolderStack(t *testing.T) {
|
||||
sta := &Stack{}
|
||||
sta.Push(&model.Album{ID: 3})
|
||||
sta.Push(&model.Album{ID: 4})
|
||||
sta.Push(&model.Album{ID: 5})
|
||||
sta.Push(&model.Album{ID: 6})
|
||||
sta.Push(&db.Album{ID: 3})
|
||||
sta.Push(&db.Album{ID: 4})
|
||||
sta.Push(&db.Album{ID: 5})
|
||||
sta.Push(&db.Album{ID: 6})
|
||||
expected := "[6, 5, 4, 3, ]"
|
||||
actual := sta.String()
|
||||
if expected != actual {
|
||||
@@ -20,12 +20,12 @@ func TestFolderStack(t *testing.T) {
|
||||
}
|
||||
//
|
||||
sta = &Stack{}
|
||||
sta.Push(&model.Album{ID: 27})
|
||||
sta.Push(&model.Album{ID: 4})
|
||||
sta.Push(&db.Album{ID: 27})
|
||||
sta.Push(&db.Album{ID: 4})
|
||||
sta.Peek()
|
||||
sta.Push(&model.Album{ID: 5})
|
||||
sta.Push(&model.Album{ID: 6})
|
||||
sta.Push(&model.Album{ID: 7})
|
||||
sta.Push(&db.Album{ID: 5})
|
||||
sta.Push(&db.Album{ID: 6})
|
||||
sta.Push(&db.Album{ID: 7})
|
||||
sta.Pop()
|
||||
expected = "[6, 5, 4, 27, ]"
|
||||
actual = sta.String()
|
||||
|
||||
Reference in New Issue
Block a user