MCPcopy Create free account
hub / github.com/sql-machine-learning/sqlflow / TestStepStandardSQL

Function TestStepStandardSQL

go/cmd/step/step_test.go:32–61  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

30}
31
32func TestStepStandardSQL(t *testing.T) {
33 if os.Getenv("SQLFLOW_TEST_DB") != "mysql" {
34 t.Skip("skip no mysql test.")
35 }
36 a := assert.New(t)
37 session := makeTestSession(database.GetTestingMySQLURL())
38 sql := `SELECT * FROM iris.train limit 5;`
39 out, e := step.GetStdout(func() error {
40 return run(sql, session)
41 })
42 // check output result
43 a.NoError(e)
44 checkHead := false
45 checkRows := 0
46 for _, line := range strings.Split(out, "\n") {
47 line = strings.TrimSpace(line)
48 response := &pb.Response{}
49 if e := proto.UnmarshalText(line, response); e == nil {
50 if response.GetHead() != nil {
51 checkHead = true
52 } else if response.GetRow() != nil {
53 checkRows++
54 } else {
55 continue
56 }
57 }
58 }
59 a.True(checkHead)
60 a.Equal(checkRows, 5)
61}
62
63func TestStepSQLWithComment(t *testing.T) {
64 if os.Getenv("SQLFLOW_TEST_DB") != "mysql" {

Callers

nothing calls this directly

Calls 4

GetTestingMySQLURLFunction · 0.92
GetStdoutFunction · 0.92
makeTestSessionFunction · 0.70
runFunction · 0.70

Tested by

no test coverage detected