Skip to content

Commit a5778af

Browse files
authored
Add test cloud
1 parent afd01f3 commit a5778af

File tree

5 files changed

+28
-8
lines changed

5 files changed

+28
-8
lines changed

.travis.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
language: android
2-
jdk:
3-
- openjdk11
42
dist: trusty
53
sudo: required
4+
jdk:
5+
- openjdk11
66

77
global:
88
# switch glibc to a memory conserving mode
@@ -54,6 +54,7 @@ before_script:
5454
- emulator -avd test -no-audio -no-window &
5555
- android-wait-for-emulator
5656
- adb shell input keyevent 82 &
57+
- export CLOUDINARY_URL=$(bash tools/get_test_cloud.sh);
5758

5859
script: ./gradlew clean connectedCheck
5960

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ ext.loadExtraProperties = { fileName ->
3737
}
3838

3939
ext.getCloudinaryUrl = { ->
40-
return findProperty("cloudinaryUrl") ?: System.getenv('CLOUDINARY_URL')
40+
return findProperty("cloudinaryUrl") ?: System.getenv('CLOUDINARY_URL') ?: System.getProperty('CLOUDINARY_URL')
4141
}
4242

4343
ext.generateAndLoadLocalGradleProperties = { rootPath ->

core/src/androidTest/java/com/cloudinary/android/AnalyticsTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ public synchronized static void setup() {
2121
public void testAnalyticsURL() {
2222
MediaManager.get().getCloudinary().config.analytics = true;
2323
String url = MediaManager.get().getCloudinary().url().generate("sample");
24-
Assert.assertEquals(url, "https://res.cloudinary.com/sdk-test/image/upload/sample?_a=AFAACAN0");
24+
Assert.assertTrue(url.contains("a=AFAACAN0"));
2525
}
2626

2727
@Test
2828
public void testAnalyticsFalseURL() {
2929
MediaManager.get().getCloudinary().config.analytics = false;
3030
String url = MediaManager.get().getCloudinary().url().generate("sample");
31-
Assert.assertEquals(url, "https://res.cloudinary.com/sdk-test/image/upload/sample");
31+
Assert.assertFalse(url.contains("a=AFAACAN0"));
3232
}
3333
}

core/src/androidTest/java/com/cloudinary/android/UploaderTest.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,11 @@ public void testRename() throws Exception {
217217
public void testExplicit() throws Exception {
218218
if (cloudinary.config.apiSecret == null)
219219
return;
220-
JSONObject result = new JSONObject(cloudinary.uploader().explicit("sample",
220+
JSONObject uploadResult = new JSONObject(cloudinary.uploader().upload(getAssetStream(TEST_IMAGE), ObjectUtils.emptyMap()));
221+
JSONObject result = new JSONObject(cloudinary.uploader().explicit(uploadResult.getString("public_id"),
221222
ObjectUtils.asMap("eager", Collections.singletonList(new Transformation().crop("scale").width(2.0)), "type", "upload")));
222-
String url = cloudinary.url().transformation(new Transformation().crop("scale").width(2.0)).format("jpg")
223-
.version(result.get("version")).generate("sample");
223+
String url = cloudinary.url().transformation(new Transformation().crop("scale").width(2.0)).format("png")
224+
.version(result.get("version")).generate(uploadResult.getString("public_id"));
224225
Assert.assertEquals(url, result.getJSONArray("eager").getJSONObject(0).get("url"));
225226
}
226227

tools/get_test_cloud.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
function test_cloud
4+
{
5+
CLOUD_DETAILS=$(curl -X POST \-H 'Content-type:application/json' \https://sub-account-testing.cloudinary.com/create_sub_account \--data '{"prefix" : "android-test-cloud"}')
6+
7+
APIKEY=$(echo "${CLOUD_DETAILS}" | python -c 'import json,sys;c=json.load(sys.stdin)["payload"];print("%s" % (c["cloudApiKey"]))')
8+
APISECRET=$(echo "${CLOUD_DETAILS}" | python -c 'import json,sys;c=json.load(sys.stdin)["payload"];print("%s" % (c["cloudApiSecret"]))')
9+
CLOUD_NAME=$(echo "${CLOUD_DETAILS}" | python -c 'import json,sys;c=json.load(sys.stdin)["payload"];print("%s" % (c["cloudName"]))')
10+
CLOUDINARY_URL=$(echo ${CLOUD_DETAILS} | python -c 'import json,sys;c=json.load(sys.stdin)["payload"];print("cloudinary://%s:%s@%s" % (c["cloudApiKey"], c["cloudApiSecret"], c["cloudName"]))')
11+
curl \
12+
-d "name=cloudinary_java_test&unsigned=true" \
13+
-X POST \
14+
https://"${APIKEY}":"${APISECRET}"@api.cloudinary.com/v1_1/"${CLOUD_NAME}"/upload_presets > /dev/null
15+
echo "${CLOUDINARY_URL}"
16+
}
17+
18+
test_cloud

0 commit comments

Comments
 (0)