@ -2,34 +2,34 @@ package model
import (
"git.nagee.dev/isthisnagee/diary/db"
"runtime/debug"
"testing"
"runtime/debug"
)
func assert_string ( t * testing . T , expected string , actual string ) {
if actual != expected {
t . Log ( string ( debug . Stack ( ) ) )
t . Log ( string ( debug . Stack ( ) ) )
t . Fatalf ( "(%v, %v)" , expected , actual )
}
}
func assert_int ( t * testing . T , expected int64 , actual int64 ) {
if actual != expected {
t . Log ( string ( debug . Stack ( ) ) )
t . Log ( string ( debug . Stack ( ) ) )
t . Fatalf ( "(%v, %v)" , expected , actual )
}
}
func assert_bool ( t * testing . T , expected bool , actual bool ) {
if actual != expected {
t . Log ( string ( debug . Stack ( ) ) )
t . Log ( string ( debug . Stack ( ) ) )
t . Fatalf ( "(%v, %v)" , expected , actual )
}
}
func assert_exists ( t * testing . T , actual interface { } ) {
if actual == nil {
t . Log ( string ( debug . Stack ( ) ) )
t . Log ( string ( debug . Stack ( ) ) )
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_2 = app . NewDiaryEntry ( "Met with Nagee @ 2PM" )
// no numEntries
// no numEntries
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_1 . Id , entries [ 1 ] . Id )
var numEntries = new ( int64 )
* numEntries = 1
var numEntries = new ( int64 )
* numEntries = 1
entries = app . GetDiaryEntries (
GetDiaryEntriesQuery {
NumEntries : numEntries ,
} ,
)
GetDiaryEntriesQuery {
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 )
teardown ( app )
}