(t *testing.T)
| 30 | } |
| 31 | |
| 32 | func 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 | |
| 63 | func TestStepSQLWithComment(t *testing.T) { |
| 64 | if os.Getenv("SQLFLOW_TEST_DB") != "mysql" { |
nothing calls this directly
no test coverage detected