@@ -2,14 +2,15 @@ package exceltesting
2
2
3
3
import (
4
4
"database/sql"
5
- "github.com/future-architect/go-exceltesting/testonly"
6
5
"net"
7
6
"os"
8
7
"path/filepath"
9
8
"reflect"
10
9
"testing"
11
10
"time"
12
11
12
+ "github.com/future-architect/go-exceltesting/testonly"
13
+
13
14
"github.com/google/go-cmp/cmp"
14
15
"github.com/google/go-cmp/cmp/cmpopts"
15
16
"github.com/jackc/pgtype"
@@ -176,10 +177,11 @@ func Test_exceltesing_Compare(t *testing.T) {
176
177
mockT := new (testing.T )
177
178
178
179
tests := []struct {
179
- name string
180
- input func (t * testing.T )
181
- wantFile string
182
- equal bool
180
+ name string
181
+ input func (t * testing.T )
182
+ wantFile string
183
+ wantSheet string
184
+ equal bool
183
185
}{
184
186
{
185
187
name : "equal" ,
@@ -195,8 +197,9 @@ func Test_exceltesing_Compare(t *testing.T) {
195
197
t .Fatal (err )
196
198
}
197
199
},
198
- wantFile : filepath .Join ("testdata" , "compare.xlsx" ),
199
- equal : true ,
200
+ wantFile : filepath .Join ("testdata" , "compare.xlsx" ),
201
+ wantSheet : "会社" ,
202
+ equal : true ,
200
203
},
201
204
{
202
205
name : "equal on exceltesing version 2.0 sheet" ,
@@ -212,8 +215,9 @@ func Test_exceltesing_Compare(t *testing.T) {
212
215
t .Fatal (err )
213
216
}
214
217
},
215
- wantFile : filepath .Join ("testdata" , "compare_v2.xlsx" ),
216
- equal : true ,
218
+ wantFile : filepath .Join ("testdata" , "compare_v2.xlsx" ),
219
+ wantSheet : "会社" ,
220
+ equal : true ,
217
221
},
218
222
{
219
223
name : "diff" ,
@@ -229,8 +233,9 @@ func Test_exceltesing_Compare(t *testing.T) {
229
233
t .Fatal (err )
230
234
}
231
235
},
232
- wantFile : filepath .Join ("testdata" , "compare.xlsx" ),
233
- equal : false ,
236
+ wantFile : filepath .Join ("testdata" , "compare.xlsx" ),
237
+ wantSheet : "会社" ,
238
+ equal : false ,
234
239
},
235
240
{
236
241
name : "fewer records of results" ,
@@ -246,8 +251,9 @@ func Test_exceltesing_Compare(t *testing.T) {
246
251
t .Fatal (err )
247
252
}
248
253
},
249
- wantFile : filepath .Join ("testdata" , "compare.xlsx" ),
250
- equal : false ,
254
+ wantFile : filepath .Join ("testdata" , "compare.xlsx" ),
255
+ wantSheet : "会社" ,
256
+ equal : false ,
251
257
},
252
258
{
253
259
name : "many records of results" ,
@@ -263,8 +269,27 @@ func Test_exceltesing_Compare(t *testing.T) {
263
269
t .Fatal (err )
264
270
}
265
271
},
266
- wantFile : filepath .Join ("testdata" , "compare.xlsx" ),
267
- equal : false ,
272
+ wantFile : filepath .Join ("testdata" , "compare.xlsx" ),
273
+ wantSheet : "会社" ,
274
+ equal : false ,
275
+ },
276
+ {
277
+ name : "partition table" ,
278
+ input : func (t * testing.T ) {
279
+ t .Helper ()
280
+ tdb := testonly .OpenTestDB (t )
281
+ defer tdb .Close ()
282
+ if _ , err := tdb .Exec (`TRUNCATE temperature;` ); err != nil {
283
+ t .Fatal (err )
284
+ }
285
+ if _ , err := tdb .Exec (`INSERT INTO temperature (ymd,value)
286
+ VALUES ('20210228',-2.0),('20210831',38.5);` ); err != nil {
287
+ t .Fatal (err )
288
+ }
289
+ },
290
+ wantFile : filepath .Join ("testdata" , "compare.xlsx" ),
291
+ wantSheet : "気温" ,
292
+ equal : true ,
268
293
},
269
294
}
270
295
for _ , tt := range tests {
@@ -274,7 +299,7 @@ func Test_exceltesing_Compare(t *testing.T) {
274
299
e := New (conn )
275
300
got := e .Compare (mockT , CompareRequest {
276
301
TargetBookPath : filepath .Join ("testdata" , "compare.xlsx" ),
277
- SheetPrefix : "" ,
302
+ SheetPrefix : tt . wantSheet ,
278
303
IgnoreSheet : nil ,
279
304
IgnoreColumns : []string {"created_at" , "updated_at" },
280
305
})
0 commit comments