@@ -57,6 +57,7 @@ func TestExportToLocalAndDownload(t *testing.T) {
57
57
}
58
58
59
59
t .Log ("start to download files" )
60
+ path := shortuuid .New ()
60
61
for _ , exportFile := range exportFilesRes .Files {
61
62
// download file
62
63
downloadRes , err := util .GetResponse (* exportFile .Url )
@@ -66,17 +67,18 @@ func TestExportToLocalAndDownload(t *testing.T) {
66
67
if downloadRes .ContentLength <= 0 {
67
68
t .Fatal ("file is empty" )
68
69
}
69
- file , err := os .Create (* exportFile .Name )
70
+ fileName := * exportFile .Name + path
71
+ file , err := os .Create (fileName )
70
72
if err != nil {
71
73
t .Fatal (err )
72
74
}
73
75
_ , err = io .Copy (file , downloadRes .Body )
74
76
// check file
75
- targetFileInfo , err := os .Stat (* exportFile . Name )
77
+ targetFileInfo , err := os .Stat (fileName )
76
78
if err != nil {
77
79
t .Fatal (err )
78
80
}
79
- assert .Equal (t , targetFileInfo .Name (), * exportFile . Name )
81
+ assert .Equal (t , targetFileInfo .Name (), fileName )
80
82
}
81
83
}
82
84
@@ -377,6 +379,23 @@ func TestExportToGCS(t *testing.T) {
377
379
assert .Equal (t , exp .Target .Gcs .Uri , gcsUri )
378
380
}
379
381
382
+ func TestCancelExport (t * testing.T ) {
383
+ ctx := context .Background ()
384
+
385
+ t .Log ("start to create export" )
386
+ res , err := CreateExport (ctx , exportClient , clusterId , nil )
387
+ if err != nil {
388
+ t .Fatal (err )
389
+ }
390
+
391
+ t .Log ("start to cancel export" )
392
+ cancelRes , h , err := exportClient .ExportServiceAPI .ExportServiceCancelExport (ctx , clusterId , * res .ExportId ).Execute ()
393
+ if util .ParseError (err , h ) != nil {
394
+ t .Fatal (util .ParseError (err , h ))
395
+ }
396
+ assert .Equal (t , * cancelRes .State , export .EXPORTSTATEENUM_CANCELED )
397
+ }
398
+
380
399
func TestMain (m * testing.M ) {
381
400
setup ()
382
401
code := m .Run ()
0 commit comments