Skip to content

Commit

Permalink
test: add integration test for newly added methods
Browse files Browse the repository at this point in the history
  • Loading branch information
grdsdev committed Mar 28, 2024
1 parent 4ab0a0e commit 059c65a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Sources/Storage/SupabaseStorage.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import _Helpers
import Foundation

public typealias SupabaseLogger = _Helpers.SupabaseLogger
public typealias SupabaseLogMessage = _Helpers.SupabaseLogMessage

public struct StorageClientConfiguration {
public let url: URL
public var headers: [String: String]
Expand Down
14 changes: 13 additions & 1 deletion Tests/StorageTests/StorageClientIntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import XCTest

final class StorageClientIntegrationTests: XCTestCase {
static var apiKey: String {
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0"
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU"
}

static var supabaseURL: String {
Expand Down Expand Up @@ -148,6 +148,18 @@ final class StorageClientIntegrationTests: XCTestCase {
)
}

func testCreateAndUploadToSignedUploadURL() async throws {
let path = "README-\(UUID().uuidString).md"
let url = try await storage.from(bucketId).createSignedUploadURL(path: path)
let key = try await storage.from(bucketId).uploadToSignedURL(
path: url.path,
token: url.token,
file: uploadData ?? Data()
)

XCTAssertEqual(key, "\(bucketId)/\(path)")
}

private func uploadTestData() async throws {
_ = try await storage.from(bucketId).upload(
path: "README.md", file: uploadData ?? Data(), options: FileOptions(cacheControl: "3600")
Expand Down
8 changes: 7 additions & 1 deletion Tests/StorageTests/SupabaseStorageClient+Test.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@ extension SupabaseStorageClient {
"Apikey": apiKey,
],
session: session,
logger: nil
logger: ConsoleLogger()
)
)
}
}

struct ConsoleLogger: SupabaseLogger {
func log(message: SupabaseLogMessage) {
print(message.description)
}
}

0 comments on commit 059c65a

Please sign in to comment.