github.com/thinktt/yowking@v0.0.0-20230805165945-51f5dd4f29f9/pkg/books/books._test.go (about) 1 package books 2 3 import ( 4 "fmt" 5 "os" 6 "testing" 7 ) 8 9 // anything outside dependencies across the app will be in this folder 10 // this is for tests with dependecies, any other unit tests shouldn't 11 // this shouldn't matter 12 func init() { 13 rootDir := os.Getenv("ROOT_DIR") 14 err := os.Chdir(rootDir + "/dist") 15 if err != nil { 16 fmt.Println(err) 17 } 18 pwd, _ := os.Getwd() 19 fmt.Println("working in", pwd) 20 } 21 22 func TestGetMove_NoBookMove(t *testing.T) { 23 testMoves := []string{"d2d4", "e7e6", "e2e4", "d7d5", "a2a3"} 24 move, err := GetMove(testMoves, "EarlyQueen.bin") 25 fmt.Println(err) 26 if move.Err != nil && *move.Err != "no book move" { 27 t.Errorf("error message should be no book string instead %s", *move.Err) 28 } 29 } 30 31 func TestGetMove_BookHasMoove(t *testing.T) { 32 testMoves := []string{} 33 move, err := GetMove(testMoves, "TalM.bin") 34 fmt.Println(err) 35 if move.CoordinateMove == "" { 36 t.Errorf("expected a move instead got none") 37 } 38 }