@@ -42,7 +42,16 @@ describe("store-s3", () => {
42
42
assert . equal ( indiekit . publication . store . info . name , "website bucket" ) ;
43
43
} ) ;
44
44
45
+ it ( "Checks if file exists" , async ( ) => {
46
+ mockS3Client . on ( GetObjectCommand ) . resolves ( { ETag : "true" } ) ;
47
+ assert . equal ( await s3 . fileExists ( "foo.md" ) , true ) ;
48
+
49
+ mockS3Client . on ( GetObjectCommand ) . rejects ( "Couldn’t get object" ) ;
50
+ assert . equal ( await s3 . fileExists ( "foo.md" ) , false ) ;
51
+ } ) ;
52
+
45
53
it ( "Creates file" , async ( ) => {
54
+ mockS3Client . on ( GetObjectCommand ) . rejects ( "Couldn’t get object" ) ;
46
55
mockS3Client . on ( PutObjectCommand ) . resolves ( { ETag : "true" } ) ;
47
56
48
57
assert . equal (
@@ -51,7 +60,14 @@ describe("store-s3", () => {
51
60
) ;
52
61
} ) ;
53
62
63
+ it ( "Doesn’t create file if already exists" , async ( ) => {
64
+ mockS3Client . on ( GetObjectCommand ) . resolves ( { ETag : "true" } ) ;
65
+
66
+ assert . equal ( await s3 . createFile ( "foo.md" , "foobar" ) , undefined ) ;
67
+ } ) ;
68
+
54
69
it ( "Throws error creating file" , async ( ) => {
70
+ mockS3Client . on ( GetObjectCommand ) . rejects ( "Couldn’t get object" ) ;
55
71
mockS3Client . on ( PutObjectCommand ) . rejects ( "Couldn’t put object" ) ;
56
72
57
73
await assert . rejects ( s3 . createFile ( "foo.md" , "" ) , {
0 commit comments