@ -2,34 +2,34 @@ package model
import (
import (
"git.nagee.dev/isthisnagee/diary/db"
"git.nagee.dev/isthisnagee/diary/db"
"runtime/debug"
"testing"
"testing"
"runtime/debug"
)
)
func assert_string ( t * testing . T , expected string , actual string ) {
func assert_string ( t * testing . T , expected string , actual string ) {
if actual != expected {
if actual != expected {
t . Log ( string ( debug . Stack ( ) ) )
t . Log ( string ( debug . Stack ( ) ) )
t . Fatalf ( "(%v, %v)" , expected , actual )
t . Fatalf ( "(%v, %v)" , expected , actual )
}
}
}
}
func assert_int ( t * testing . T , expected int64 , actual int64 ) {
func assert_int ( t * testing . T , expected int64 , actual int64 ) {
if actual != expected {
if actual != expected {
t . Log ( string ( debug . Stack ( ) ) )
t . Log ( string ( debug . Stack ( ) ) )
t . Fatalf ( "(%v, %v)" , expected , actual )
t . Fatalf ( "(%v, %v)" , expected , actual )
}
}
}
}
func assert_bool ( t * testing . T , expected bool , actual bool ) {
func assert_bool ( t * testing . T , expected bool , actual bool ) {
if actual != expected {
if actual != expected {
t . Log ( string ( debug . Stack ( ) ) )
t . Log ( string ( debug . Stack ( ) ) )
t . Fatalf ( "(%v, %v)" , expected , actual )
t . Fatalf ( "(%v, %v)" , expected , actual )
}
}
}
}
func assert_exists ( t * testing . T , actual interface { } ) {
func assert_exists ( t * testing . T , actual interface { } ) {
if actual == nil {
if actual == nil {
t . Log ( string ( debug . Stack ( ) ) )
t . Log ( string ( debug . Stack ( ) ) )
t . Fatalf ( "Unexpected nil: %s" , actual )
t . Fatalf ( "Unexpected nil: %s" , actual )
}
}
}
}
@ -111,27 +111,25 @@ func TestGetDiaryEntries(t *testing.T) {
var result_1 = app . NewDiaryEntry ( "Met with Nagee @ 1PM" )
var result_1 = app . NewDiaryEntry ( "Met with Nagee @ 1PM" )
var result_2 = app . NewDiaryEntry ( "Met with Nagee @ 2PM" )
var result_2 = app . NewDiaryEntry ( "Met with Nagee @ 2PM" )
// no numEntries
// no numEntries
entries := app . GetDiaryEntries (
entries := app . GetDiaryEntries (
GetDiaryEntriesQuery { } ,
GetDiaryEntriesQuery { } ,
)
)
assert_int ( t , int64 ( len ( entries ) ) , 2 )
assert_int ( t , int64 ( len ( entries ) ) , 2 )
assert_int ( t , result_2 . Id , entries [ 0 ] . Id )
assert_int ( t , result_2 . Id , entries [ 0 ] . Id )
assert_int ( t , result_1 . Id , entries [ 1 ] . Id )
assert_int ( t , result_1 . Id , entries [ 1 ] . Id )
var numEntries = new ( int64 )
var numEntries = new ( int64 )
* numEntries = 1
* numEntries = 1
entries = app . GetDiaryEntries (
entries = app . GetDiaryEntries (
GetDiaryEntriesQuery {
GetDiaryEntriesQuery {
NumEntries : numEntries ,
NumEntries : numEntries ,
} ,
} ,
)
)
assert_int ( t , int64 ( len ( entries ) ) , 1 )
assert_int ( t , int64 ( len ( entries ) ) , 1 )
assert_int ( t , result_2 . Id , entries [ 0 ] . Id )
assert_int ( t , result_2 . Id , entries [ 0 ] . Id )
teardown ( app )
teardown ( app )
}
}