func TestFindLanguages(t *testing.T) {
	resetDB()
	populateDB()

	var ls Languages
	var err error

	// normal
	ls, err = FindLanguages()
	if err != nil {
		t.Fatal(err)
	}
	if got, want := len(ls), 99; got != want {
		t.Error("len(ls) = %d; want %d", got, want)
	}
	if got, want := ls[0].Name, "Mr. Tester"; got != want {
		t.Errorf("ls[0].Name = %s; want %s", got, want)
	}

	// sql patial
	ls, err = FindLanguages(go2sql.NewSQL("order by id desc limit 10"))
	if err != nil {
		t.Fatal(err)
	}
	if got, want := len(ls), 10; got != want {
		t.Error("len(ls) = %d; want %d", got, want)
	}
	if got, want := ls[0].ID, uint(99); got != want {
		t.Errorf("ls[0].Name = %d; want %d", got, want)
	}

	// db specification
	go2sql.SetDefaultDB(nil)
	_, err = FindLanguages()
	if err == nil {
		t.Error("expect error for nil db")
	}
	ls, err = FindLanguages(go2sql.DB(db))
	if err != nil {
		t.Fatal(err)
	}
	if got, want := ls[0].Name, "Mr. Tester"; got != want {
		t.Errorf("ls[0].Name = %s; want %s", got, want)
	}
	go2sql.SetDefaultDB(db)

	// selects
	ls, err = FindLanguages(go2sql.Selects{"id", "words_stat"})
	if err != nil {
		t.Fatal(err)
	}
	if got, want := ls[0].Name, ""; got != want {
		t.Errorf("ls[0].Name = %s; want %s", got, want)
	}
	if got, want := ls[0].WordsCount, uint(1); got != want {
		t.Errorf("ls[0].Name = %d; want %d", got, want)
	}
}
func init() {
	var err error
	db, err = sql.Open("mysql", "root:@/go2sql_example")
	if err != nil {
		panic(err)
	}

	go2sql.SetDefaultDB(db)
}