@@ -5,10 +5,10 @@ import util from 'util';
5
5
import { afterAll , beforeAll , describe , expect , it } from 'vitest' ;
6
6
import IBMi from '../../IBMi' ;
7
7
import { Tools } from '../../Tools' ;
8
- import { CONNECTION_TIMEOUT , disposeConnection , newConnection } from '../connection' ;
9
8
import { ModuleExport , ProgramExportImportInfo } from '../../types' ;
9
+ import { CONNECTION_TIMEOUT , disposeConnection , newConnection } from '../connection' ;
10
10
11
- describe ( 'Content Tests' , { concurrent : true } , ( ) => {
11
+ describe ( 'Content Tests' , { concurrent : true } , ( ) => {
12
12
let connection : IBMi
13
13
beforeAll ( async ( ) => {
14
14
connection = await newConnection ( ) ;
@@ -521,7 +521,7 @@ describe('Content Tests', {concurrent: true}, () => {
521
521
expect ( error ) . toBeInstanceOf ( Tools . SqlError ) ;
522
522
expect ( error . sqlstate ) . toBe ( '38501' ) ;
523
523
}
524
- } , { timeout : 25000 } ) ;
524
+ } , { timeout : 25000 } ) ;
525
525
526
526
it ( 'Test @clCommand + select statement' , async ( ) => {
527
527
const content = connection . getContent ( ) ;
@@ -717,4 +717,40 @@ describe('Content Tests', {concurrent: true}, () => {
717
717
}
718
718
} ) ;
719
719
} ) ;
720
+
721
+ it ( 'Copy and move streamfiles' , async ( ) => {
722
+ const content = connection . getContent ( ) ;
723
+ await connection . withTempDirectory ( async directory => {
724
+ const checkFile = async ( path : string , ccsid : number ) => {
725
+ expect ( await content . testStreamFile ( path , "w" ) ) . toBe ( true ) ;
726
+ const attributes = await content . getAttributes ( path , "CCSID" ) ;
727
+ expect ( attributes ) . toBeDefined ( ) ;
728
+ expect ( attributes ! [ "CCSID" ] ) . toBe ( String ( ccsid ) ) ;
729
+ }
730
+
731
+ const unicodeFile = "unicode" ;
732
+ const ccsid37File = "ccsid37" ;
733
+
734
+ await content . createStreamFile ( `${ directory } /${ unicodeFile } ` ) ;
735
+ await checkFile ( `${ directory } /${ unicodeFile } ` , 1208 ) ;
736
+ await content . createStreamFile ( `${ directory } /${ ccsid37File } ` ) ;
737
+ await connection . sendCommand ( { command : `${ connection . remoteFeatures . attr } ${ directory } /${ ccsid37File } CCSID=37` } ) ;
738
+ await checkFile ( `${ directory } /${ ccsid37File } ` , 37 ) ;
739
+ const files = [ `${ directory } /${ unicodeFile } ` , `${ directory } /${ ccsid37File } ` ] ;
740
+
741
+ expect ( ( await connection . sendCommand ( { command : `mkdir ${ directory } /copy` } ) ) . code ) . toBe ( 0 ) ;
742
+ expect ( ( await content . copy ( files , `${ directory } /copy` ) ) . code ) . toBe ( 0 ) ;
743
+ expect ( await content . testStreamFile ( `${ directory } /${ unicodeFile } ` , "f" ) ) . toBe ( true ) ;
744
+ expect ( await content . testStreamFile ( `${ directory } /${ ccsid37File } ` , "f" ) ) . toBe ( true ) ;
745
+ await checkFile ( `${ directory } /copy/${ unicodeFile } ` , 1208 ) ;
746
+ await checkFile ( `${ directory } /copy/${ ccsid37File } ` , 37 ) ;
747
+
748
+ expect ( ( await connection . sendCommand ( { command : `mkdir ${ directory } /move` } ) ) . code ) . toBe ( 0 ) ;
749
+ expect ( ( await content . move ( files , `${ directory } /move` ) ) . code ) . toBe ( 0 ) ;
750
+ expect ( await content . testStreamFile ( `${ directory } /${ unicodeFile } ` , "f" ) ) . toBe ( false ) ;
751
+ expect ( await content . testStreamFile ( `${ directory } /${ ccsid37File } ` , "f" ) ) . toBe ( false ) ;
752
+ await checkFile ( `${ directory } /move/${ unicodeFile } ` , 1208 ) ;
753
+ await checkFile ( `${ directory } /move/${ ccsid37File } ` , 37 ) ;
754
+ } ) ;
755
+ } ) ;
720
756
} ) ;
0 commit comments