Exemple #1
0
func TestQuero(t *testing.T) {
	db, err := sql.Open("mysql", "root:@tcp(localhost:3306)/test")

	if err != nil {
		flux.FatalFailed(t, "Creating sql connection: %+s", err)
	}

	defer db.Close()

	prepareTable(t, db)

	var ws sync.WaitGroup
	ws.Add(1)

	reader := flux.FileLoader()
	qo := Quero(db)
	reader.Bind(qo, true)

	qo.React(func(r flux.Reactor, err error, d interface{}) {
		ws.Done()
		if err != nil {
			flux.FatalFailed(t, "Failed in Building sql.Statement, Error Received: %+s", err)
		}
		log.Printf("Model data: %+q", d)
		flux.LogPassed(t, "Successful created sql.Statement")
	}, true)

	reader.Send("./../../fixtures/models.dq")

	defer qo.Close()

	ws.Wait()

	dropTables(t, db)
}
Exemple #2
0
func TestEngine(t *testing.T) {
	var ws sync.WaitGroup
	ws.Add(1)

	reader := flux.FileLoader()
	qo := BasicQueroEngine()

	reader.Bind(qo, true)

	qo.React(func(r flux.Reactor, err error, d interface{}) {
		ws.Done()
		if err != nil {
			flux.FatalFailed(t, "Failed in Building sql.Statement, Error Received: %+s", err)
		}
		flux.LogPassed(t, "Successful created sql.Statement")
	}, true)

	reader.Send("./../../fixtures/dataset.dq")

	defer qo.Close()
	ws.Wait()
}