Skip to content

Commit

Permalink
Create unit test to fix issue bazel-xcode#177
Browse files Browse the repository at this point in the history
  • Loading branch information
rquesada committed Jun 22, 2021
1 parent db17580 commit bdda9c3
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Tests/PodToBUILDTests/PodStoreTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,39 @@ class PodStoreTests: XCTestCase {
XCTAssertTrue(shell.executed(encodedCommand: extract.0))
}

func testZipExtractionWithSpecialCharacteres() {

let fileName = "v4.0.1.zip"
let urlString = "https://github.com/danielgindi/Charts/archive/refs/tags/" + fileName
let nameOfPod = "Charts"

let fetchOptionsCharts = FetchOptions(podName: nameOfPod,
url: urlString,
trace: false,
subDir: nil)

let downloadPathCharts = "%TMP%/" + nameOfPod + "-" + fileName

let hasDir = MakeShellInvocation("/bin/[", arguments: ["-e",
cacheRoot(forPod: nameOfPod, url: urlString),
"]"], exitCode: 1)

let extract = MakeShellInvocation("/bin/sh",
arguments: ["-c", RepoActions.unzipTransaction(
rootDir: escape(extractDir),
fileName: escape(downloadPathCharts)
)],
exitCode: 0)
let shell = LogicalShellContext(commandInvocations: [
hasDir,
extract
])

RepoActions.fetch(shell: shell, fetchOptions: fetchOptionsCharts)
XCTAssertTrue(shell.executed(encodedCommand:LogicalShellContext.encodeDownload(url: URL(string: fetchOptionsCharts.url)!, toFile: downloadPathCharts)))
XCTAssertTrue(shell.executed(encodedCommand: extract.0))
}

func testCachedDownload() {
let hasDir = MakeShellInvocation("/bin/[", arguments: ["-e", cacheRoot(forPod: testPodName, url: "http://pinner.com/foo.zip"), "]"], value: 0)
let shell = LogicalShellContext(commandInvocations: [
Expand Down

0 comments on commit bdda9c3

Please sign in to comment.