-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set correct content type of file in S3 storage (#151)
* Set correct content type of file in S3 storage * Fix build on Ubuntu
- Loading branch information
1 parent
1d28c06
commit b38b038
Showing
6 changed files
with
248 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
Tests/VernissageServerTests/ExtensionsTests/String+Url.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
// | ||
// https://mczachurski.dev | ||
// Copyright © 2024 Marcin Czachurski and the repository contributors. | ||
// Licensed under the Apache License 2.0. | ||
// | ||
|
||
@testable import VernissageServer | ||
import Testing | ||
|
||
@Suite("String URL tests") | ||
struct StringUrlTests { | ||
|
||
@Test("Simple file extension should be recognized") | ||
func simpleFileExtensionShouldBeRecognized() async throws { | ||
|
||
// Arrange. | ||
let fileName = "file.JPG" | ||
|
||
// Act. | ||
let pathExtension = fileName.pathExtension | ||
|
||
// Assert. | ||
#expect(pathExtension == "JPG", "JPG extension should be returned") | ||
} | ||
|
||
@Test("Complex file extension should be recognized") | ||
func complesFileExtensionShouldBeRecognized() async throws { | ||
|
||
// Arrange. | ||
let fileName = "file://path/jakies/file-123.png" | ||
|
||
// Act. | ||
let pathExtension = fileName.pathExtension | ||
|
||
// Assert. | ||
#expect(pathExtension == "png", "png extension should be returned") | ||
} | ||
|
||
@Test("JPG file extension should be recognized as image/jpeg mime type") | ||
func JPGFileExtensionShouldBeRecognizedAsImageJpegMimeType() async throws { | ||
|
||
// Arrange. | ||
let fileName = "file.JPG" | ||
|
||
// Act. | ||
let mimeType = fileName.mimeType | ||
|
||
// Assert. | ||
#expect(mimeType == "image/jpeg", "JPG extension should be returned") | ||
} | ||
|
||
@Test("jpg file extension should be recognized as image/jpeg mime type") | ||
func jpgFileExtensionShouldBeRecognizedAsImageJpegMimeType() async throws { | ||
|
||
// Arrange. | ||
let fileName = "file.jpg" | ||
|
||
// Act. | ||
let mimeType = fileName.mimeType | ||
|
||
// Assert. | ||
#expect(mimeType == "image/jpeg", "jpg extension should be returned") | ||
} | ||
|
||
@Test("JPEG file extension should be recognized as image/jpeg mime type") | ||
func JPEGFileExtensionShouldBeRecognizedAsImageJpegMimeType() async throws { | ||
|
||
// Arrange. | ||
let fileName = "file.JPEG" | ||
|
||
// Act. | ||
let mimeType = fileName.mimeType | ||
|
||
// Assert. | ||
#expect(mimeType == "image/jpeg", "JPEG extension should be returned") | ||
} | ||
|
||
@Test("jpeg file extension should be recognized as image/jpeg mime type") | ||
func jpegFileExtensionShouldBeRecognizedAsImageJpegMimeType() async throws { | ||
|
||
// Arrange. | ||
let fileName = "file.jpeg" | ||
|
||
// Act. | ||
let mimeType = fileName.mimeType | ||
|
||
// Assert. | ||
#expect(mimeType == "image/jpeg", "jpeg extension should be returned") | ||
} | ||
|
||
@Test("PNG file extension should be recognized as image/png mime type") | ||
func PNGFileExtensionShouldBeRecognizedAsImageJpegMimeType() async throws { | ||
|
||
// Arrange. | ||
let fileName = "file.PNG" | ||
|
||
// Act. | ||
let mimeType = fileName.mimeType | ||
|
||
// Assert. | ||
#expect(mimeType == "image/png", "PNG extension should be returned") | ||
} | ||
|
||
@Test("png file extension should be recognized as image/png mime type") | ||
func pngFileExtensionShouldBeRecognizedAsImageJpegMimeType() async throws { | ||
|
||
// Arrange. | ||
let fileName = "file.png" | ||
|
||
// Act. | ||
let mimeType = fileName.mimeType | ||
|
||
// Assert. | ||
#expect(mimeType == "image/png", "jpeg extension should be returned") | ||
} | ||
} | ||
|