Skip to content

Commit

Permalink
test(file): more rigid specified file key test
Browse files Browse the repository at this point in the history
- New intl. applications share a gluttony bucket.
- Users may use `/` in the specified key.
  • Loading branch information
weakish committed Dec 11, 2020
1 parent 303df9e commit 918e5ca
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions test/MasterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public function testSaveWithSpecifiedKey() {
$file = File::createWithData("test.txt", "Hello World!");
$file->setKey("abc");
$this->assertEquals("abc", $file->getKey());
// $this->setExpectedException("LeanCloud\CloudException", null, 603);
$file->save();
$this->assertNotEmpty($file->getObjectId());
$this->assertNotEmpty($file->getName());
Expand All @@ -28,9 +27,13 @@ public function testSaveWithSpecifiedKey() {
$parsedUrl = parse_url($url);
$path = $parsedUrl["path"];
$oldSchoolAwsS3FileUrlPrefix = "/avos-cloud-";
$newAwsS3GluttonyUrlPrefix = "https://lc-gluttony";
if (substr($path, 0, strlen($oldSchoolAwsS3FileUrlPrefix)) === $oldSchoolAwsS3FileUrlPrefix) {
$splitPath = explode("/", $path);
$splitPath = explode("/", $path, 3);
$this->assertEquals("abc", $splitPath[2]);
} else if (substr($url, 0, strlen($newAwsS3GluttonyUrlPrefix)) === $newAwsS3GluttonyUrlPrefix) {
$gluttonyPath = "/" + substr(getenv("LEANCLOUD_APP_KEY"), 0, 12) + "/abc";
$this->assertEquals($gluttonyPath, $path);
} else {
$this->assertEquals("/abc", $path);
}
Expand Down

0 comments on commit 918e5ca

Please sign in to comment.