@@ -18,14 +18,14 @@ import (
1818 "fmt"
1919 "testing"
2020
21+ "github.com/GoogleCloudPlatform/spanner-migration-tool/expressions_api"
2122 "github.com/GoogleCloudPlatform/spanner-migration-tool/profiles"
2223 "github.com/GoogleCloudPlatform/spanner-migration-tool/sources/common"
2324 "github.com/GoogleCloudPlatform/spanner-migration-tool/sources/mysql"
2425 "github.com/stretchr/testify/assert"
2526 "github.com/stretchr/testify/mock"
2627)
2728
28-
2929func TestSchemaFromDatabase (t * testing.T ) {
3030 targetProfile := profiles.TargetProfile {
3131 Conn : profiles.TargetProfileConnection {
@@ -65,88 +65,88 @@ func TestSchemaFromDatabase(t *testing.T) {
6565 sourceProfileCloudDefault := profiles.SourceProfile {}
6666 // Avoid getting/setting env variables in the unit tests.
6767 testCases := []struct {
68- name string
69- sourceProfile profiles.SourceProfile
70- getInfoError error
71- processSchemaError error
72- errorExpected bool
68+ name string
69+ sourceProfile profiles.SourceProfile
70+ getInfoError error
71+ processSchemaError error
72+ errorExpected bool
7373 }{
7474 {
75- name : "successful source profile config for bulk migration" ,
76- sourceProfile : sourceProfileConfigBulk ,
77- getInfoError : nil ,
75+ name : "successful source profile config for bulk migration" ,
76+ sourceProfile : sourceProfileConfigBulk ,
77+ getInfoError : nil ,
7878 processSchemaError : nil ,
79- errorExpected : false ,
79+ errorExpected : false ,
8080 },
8181 {
82- name : "source profile config for bulk migration: get info error" ,
83- sourceProfile : sourceProfileConfigBulk ,
84- getInfoError : fmt .Errorf ("error" ),
82+ name : "source profile config for bulk migration: get info error" ,
83+ sourceProfile : sourceProfileConfigBulk ,
84+ getInfoError : fmt .Errorf ("error" ),
8585 processSchemaError : nil ,
86- errorExpected : true ,
86+ errorExpected : true ,
8787 },
8888 {
89- name : "source profile config for bulk migration: process schema error" ,
90- sourceProfile : sourceProfileConfigBulk ,
91- getInfoError : nil ,
89+ name : "source profile config for bulk migration: process schema error" ,
90+ sourceProfile : sourceProfileConfigBulk ,
91+ getInfoError : nil ,
9292 processSchemaError : fmt .Errorf ("error" ),
93- errorExpected : true ,
93+ errorExpected : true ,
9494 },
9595 {
96- name : "successful source profile config for dataflow migration" ,
97- sourceProfile : sourceProfileConfigDataflow ,
98- getInfoError : nil ,
96+ name : "successful source profile config for dataflow migration" ,
97+ sourceProfile : sourceProfileConfigDataflow ,
98+ getInfoError : nil ,
9999 processSchemaError : nil ,
100- errorExpected : false ,
100+ errorExpected : false ,
101101 },
102102 {
103- name : "source profile config for dataflow migration: get info error" ,
104- sourceProfile : sourceProfileConfigDataflow ,
105- getInfoError : fmt .Errorf ("error" ),
103+ name : "source profile config for dataflow migration: get info error" ,
104+ sourceProfile : sourceProfileConfigDataflow ,
105+ getInfoError : fmt .Errorf ("error" ),
106106 processSchemaError : nil ,
107- errorExpected : true ,
107+ errorExpected : true ,
108108 },
109109 {
110- name : "source profile config for dms migration" ,
111- sourceProfile : sourceProfileConfigDms ,
112- getInfoError : nil ,
110+ name : "source profile config for dms migration" ,
111+ sourceProfile : sourceProfileConfigDms ,
112+ getInfoError : nil ,
113113 processSchemaError : nil ,
114- errorExpected : true ,
114+ errorExpected : true ,
115115 },
116116 {
117- name : "invalid source profile config" ,
118- sourceProfile : sourceProfileConfigInvalid ,
119- getInfoError : nil ,
117+ name : "invalid source profile config" ,
118+ sourceProfile : sourceProfileConfigInvalid ,
119+ getInfoError : nil ,
120120 processSchemaError : nil ,
121- errorExpected : true ,
121+ errorExpected : true ,
122122 },
123123 {
124- name : "successful source profile cloud sql" ,
125- sourceProfile : sourceProfileCloudSql ,
126- getInfoError : nil ,
124+ name : "successful source profile cloud sql" ,
125+ sourceProfile : sourceProfileCloudSql ,
126+ getInfoError : nil ,
127127 processSchemaError : nil ,
128- errorExpected : false ,
128+ errorExpected : false ,
129129 },
130130 {
131- name : "source profile cloud sql: get info error" ,
132- sourceProfile : sourceProfileCloudSql ,
133- getInfoError : fmt .Errorf ("error" ),
131+ name : "source profile cloud sql: get info error" ,
132+ sourceProfile : sourceProfileCloudSql ,
133+ getInfoError : fmt .Errorf ("error" ),
134134 processSchemaError : nil ,
135- errorExpected : true ,
135+ errorExpected : true ,
136136 },
137137 {
138- name : "successful source profile default" ,
139- sourceProfile : sourceProfileCloudDefault ,
140- getInfoError : nil ,
138+ name : "successful source profile default" ,
139+ sourceProfile : sourceProfileCloudDefault ,
140+ getInfoError : nil ,
141141 processSchemaError : nil ,
142- errorExpected : false ,
142+ errorExpected : false ,
143143 },
144144 {
145- name : "source profile default: get info error" ,
146- sourceProfile : sourceProfileCloudDefault ,
147- getInfoError : fmt .Errorf ("error" ),
145+ name : "source profile default: get info error" ,
146+ sourceProfile : sourceProfileCloudDefault ,
147+ getInfoError : fmt .Errorf ("error" ),
148148 processSchemaError : nil ,
149- errorExpected : true ,
149+ errorExpected : true ,
150150 },
151151 }
152152
@@ -159,8 +159,10 @@ func TestSchemaFromDatabase(t *testing.T) {
159159 gim .On ("GetInfoSchema" , "migration-project-id" , mock .Anything , mock .Anything , mock .Anything , mock .Anything , mock .Anything ).Return (mysql.InfoSchemaImpl {}, tc .getInfoError )
160160 ps .On ("ProcessSchema" , mock .Anything , mock .Anything , mock .Anything , mock .Anything , mock .Anything , mock .Anything , mock .Anything ).Return (tc .processSchemaError )
161161
162- s := SchemaFromSourceImpl {}
162+ s := SchemaFromSourceImpl {
163+ DdlVerifier : & expressions_api.MockDDLVerifier {},
164+ }
163165 _ , err := s .schemaFromDatabase ("migration-project-id" , tc .sourceProfile , targetProfile , & gim , & ps )
164166 assert .Equal (t , tc .errorExpected , err != nil , tc .name )
165167 }
166- }
168+ }
0 commit comments