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

Function TestTrainCodegen

go/codegen/tensorflow/codegen_test.go:30–61  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

28 return &pb.Session{DbConnStr: database.GetTestingMySQLURL()}
29}
30func TestTrainCodegen(t *testing.T) {
31 driver := os.Getenv("SQLFLOW_TEST_DB")
32
33 a := assert.New(t)
34 tir := ir.MockTrainStmt(false)
35 _, err := Train(tir, mockSession())
36 a.NoError(err)
37
38 pir := ir.MockPredStmt(tir)
39
40 sess := &pb.Session{
41 Token: "",
42 DbConnStr: "",
43 ExitOnSubmit: false,
44 UserId: "",
45 }
46 if driver == "hive" {
47 sess.DbConnStr = database.GetTestingHiveURL()
48 }
49 code, err := Pred(pir, sess)
50 a.NoError(err)
51
52 if driver == "hive" {
53 r, _ := regexp.Compile(`hive_location=(.*)`)
54 a.Contains(r.FindStringSubmatch(code)[1], "/sqlflow")
55 r, _ = regexp.Compile(`hdfs_namenode_addr=(.*)&`)
56 a.Equal(r.FindStringSubmatch(code)[1], "")
57 } else {
58 r, _ := regexp.Compile(`hive_location=(.*)`)
59 a.Equal(0, len(r.FindStringSubmatch(code)))
60 }
61}
62
63func TestTrainWithModelRepoImage(t *testing.T) {
64 a := assert.New(t)

Callers

nothing calls this directly

Calls 6

MockTrainStmtFunction · 0.92
MockPredStmtFunction · 0.92
GetTestingHiveURLFunction · 0.92
TrainFunction · 0.70
mockSessionFunction · 0.70
PredFunction · 0.70

Tested by

no test coverage detected