Skip to content

Commit

Permalink
Merge pull request #193 from algolia/fix/ktor-1.3
Browse files Browse the repository at this point in the history
Release 2.3.0
  • Loading branch information
spinach authored Feb 24, 2020
2 parents 7665ed3 + 29038a8 commit 6fd4cce
Show file tree
Hide file tree
Showing 13 changed files with 301 additions and 15 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 2.3.0

- Use Kotlin client `1.3.1`
- Updated Ktor to `1.3.0`

# 2.2.2

- Use Kotlin client `1.2.2`
Expand Down
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source "https://rubygems.org"

gem "fastlane"
161 changes: 161 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (3.0.2)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
atomos (0.1.3)
babosa (1.0.3)
claide (1.0.3)
colored (1.2)
colored2 (3.1.2)
commander-fastlane (4.4.6)
highline (~> 1.7.2)
declarative (0.0.10)
declarative-option (0.1.0)
digest-crc (0.4.1)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
dotenv (2.7.5)
emoji_regex (1.0.1)
excon (0.72.0)
faraday (0.17.3)
multipart-post (>= 1.2, < 3)
faraday-cookie_jar (0.0.6)
faraday (>= 0.7.4)
http-cookie (~> 1.0.0)
faraday_middleware (0.13.1)
faraday (>= 0.7.4, < 1.0)
fastimage (2.1.7)
fastlane (2.142.0)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.3, < 3.0.0)
babosa (>= 1.0.2, < 2.0.0)
bundler (>= 1.12.0, < 3.0.0)
colored
commander-fastlane (>= 4.4.6, < 5.0.0)
dotenv (>= 2.1.1, < 3.0.0)
emoji_regex (>= 0.1, < 2.0)
excon (>= 0.71.0, < 1.0.0)
faraday (~> 0.17)
faraday-cookie_jar (~> 0.0.6)
faraday_middleware (~> 0.13.1)
fastimage (>= 2.1.0, < 3.0.0)
gh_inspector (>= 1.1.2, < 2.0.0)
google-api-client (>= 0.29.2, < 0.37.0)
google-cloud-storage (>= 1.15.0, < 2.0.0)
highline (>= 1.7.2, < 2.0.0)
json (< 3.0.0)
jwt (~> 2.1.0)
mini_magick (>= 4.9.4, < 5.0.0)
multi_xml (~> 0.5)
multipart-post (~> 2.0.0)
plist (>= 3.1.0, < 4.0.0)
public_suffix (~> 2.0.0)
rubyzip (>= 1.3.0, < 2.0.0)
security (= 0.1.3)
simctl (~> 1.6.3)
slack-notifier (>= 2.0.0, < 3.0.0)
terminal-notifier (>= 2.0.0, < 3.0.0)
terminal-table (>= 1.4.5, < 2.0.0)
tty-screen (>= 0.6.3, < 1.0.0)
tty-spinner (>= 0.8.0, < 1.0.0)
word_wrap (~> 1.0.0)
xcodeproj (>= 1.13.0, < 2.0.0)
xcpretty (~> 0.3.0)
xcpretty-travis-formatter (>= 0.0.3)
gh_inspector (1.1.3)
google-api-client (0.36.4)
addressable (~> 2.5, >= 2.5.1)
googleauth (~> 0.9)
httpclient (>= 2.8.1, < 3.0)
mini_mime (~> 1.0)
representable (~> 3.0)
retriable (>= 2.0, < 4.0)
signet (~> 0.12)
google-cloud-core (1.5.0)
google-cloud-env (~> 1.0)
google-cloud-errors (~> 1.0)
google-cloud-env (1.3.0)
faraday (~> 0.11)
google-cloud-errors (1.0.0)
google-cloud-storage (1.25.1)
addressable (~> 2.5)
digest-crc (~> 0.4)
google-api-client (~> 0.33)
google-cloud-core (~> 1.2)
googleauth (~> 0.9)
mini_mime (~> 1.0)
googleauth (0.10.0)
faraday (~> 0.12)
jwt (>= 1.4, < 3.0)
memoist (~> 0.16)
multi_json (~> 1.11)
os (>= 0.9, < 2.0)
signet (~> 0.12)
highline (1.7.10)
http-cookie (1.0.3)
domain_name (~> 0.5)
httpclient (2.8.3)
json (2.3.0)
jwt (2.1.0)
memoist (0.16.2)
mini_magick (4.10.1)
mini_mime (1.0.2)
multi_json (1.14.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
nanaimo (0.2.6)
naturally (2.2.0)
os (1.0.1)
plist (3.5.0)
public_suffix (2.0.5)
representable (3.0.4)
declarative (< 0.1.0)
declarative-option (< 0.2.0)
uber (< 0.2.0)
retriable (3.1.2)
rouge (2.0.7)
rubyzip (1.3.0)
security (0.1.3)
signet (0.12.0)
addressable (~> 2.3)
faraday (~> 0.9)
jwt (>= 1.5, < 3.0)
multi_json (~> 1.10)
simctl (1.6.8)
CFPropertyList
naturally
slack-notifier (2.3.2)
terminal-notifier (2.0.0)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
tty-cursor (0.7.1)
tty-screen (0.7.1)
tty-spinner (0.9.3)
tty-cursor (~> 0.7)
uber (0.1.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.6)
unicode-display_width (1.6.1)
word_wrap (1.0.0)
xcodeproj (1.15.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.2.6)
xcpretty (0.3.0)
rouge (~> 2.0.7)
xcpretty-travis-formatter (1.0.0)
xcpretty (~> 0.2, >= 0.0.7)

PLATFORMS
ruby

DEPENDENCIES
fastlane

BUNDLED WITH
1.17.2
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/dependency/Library.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ object Library: Dependency {

override val group = "com.algolia"
override val artifact = "instantsearch"
override val version = "2.2.2"
override val version = "2.3.0"

val packageName = "$group:$artifact-android"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ object AlgoliaClient : Dependency {

override val group = "com.algolia"
override val artifact = "algoliasearch-client-kotlin"
override val version = "1.2.2"
override val version = "1.3.1"
}
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/dependency/network/Ktor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ object Ktor : Dependency {

override val group = "io.ktor"
override val artifact = "ktor"
override val version = "1.2.6"
override val version = "1.3.0"
}
2 changes: 2 additions & 0 deletions fastlane/Appfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
json_key_file("") # Path to the json secret file - Follow https://docs.fastlane.tools/actions/supply/#setup to get one
package_name("com.algolia.instantsearch") # e.g. com.krausefx.app
28 changes: 28 additions & 0 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
fastlane_version "2.62.1"

default_platform :android

platform :android do

desc "Runs all the tests"
lane :test do
gradle(tasks: ["jvmTest"])
end

# You can define as many lanes as you want

after_all do |lane|
# This block is called, only if the executed lane was successful

# slack(
# message: "Successfully deployed new App Update."
# )
end

error do |lane, exception|
# slack(
# message: exception.message,
# success: false
# )
end
end
29 changes: 29 additions & 0 deletions fastlane/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
fastlane documentation
================
# Installation

Make sure you have the latest version of the Xcode command line tools installed:

```
xcode-select --install
```

Install _fastlane_ using
```
[sudo] gem install fastlane -NV
```
or alternatively using `brew cask install fastlane`

# Available Actions
## Android
### android test
```
fastlane android test
```
Runs all the tests

----

This README.md is auto-generated and will be re-generated every time [fastlane](https://fastlane.tools) is run.
More information about fastlane can be found on [fastlane.tools](https://fastlane.tools).
The documentation of fastlane can be found on [docs.fastlane.tools](https://docs.fastlane.tools).
23 changes: 23 additions & 0 deletions fastlane/report.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite name="fastlane.lanes">




<testcase classname="fastlane.lanes" name="0: Verifying fastlane version" time="0.0151">

</testcase>


<testcase classname="fastlane.lanes" name="1: default_platform" time="0.000967">

</testcase>


<testcase classname="fastlane.lanes" name="2: jvmTest" time="1.57988">

</testcase>

</testsuite>
</testsuites>
51 changes: 43 additions & 8 deletions helper/src/commonTest/kotlin/Client.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,79 @@ import com.algolia.search.configuration.ConfigurationSearch
import com.algolia.search.model.APIKey
import com.algolia.search.model.ApplicationID
import com.algolia.search.model.response.ResponseSearch
import com.algolia.search.model.response.ResponseSearchForFacets
import io.ktor.client.engine.mock.MockEngine
import io.ktor.client.engine.mock.respond
import io.ktor.client.engine.mock.respondBadRequest
import io.ktor.client.features.logging.LogLevel
import io.ktor.client.request.HttpResponseData
import io.ktor.http.ContentType
import io.ktor.http.headersOf
import kotlinx.coroutines.io.ByteReadChannel
import io.ktor.utils.io.ByteReadChannel
import kotlinx.serialization.KSerializer
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonConfiguration

val JsonNoDefaults = Json(JsonConfiguration.Stable.copy(encodeDefaults = false))

fun mockClient(
response: HttpResponseData = respondSearch()
response: HttpResponseData? = null
): ClientSearch {
val mockEngine = if (response != null) MockEngine { response } else { defaultMockEngine }
return mockClient(mockEngine)
}

fun mockClient(
mockEngine: MockEngine): ClientSearch {
return ClientSearch(
ConfigurationSearch(
ApplicationID("A"),
APIKey("B"),
engine = MockEngine { response },
engine = mockEngine,
logLevel = LogLevel.ALL
)
)
}

val responseSearch = ResponseSearch()

fun respondSearch(response: ResponseSearch = responseSearch) = respondJson(response, ResponseSearch.serializer())

fun <T> respondJson(response: T, serializer: KSerializer<T>): HttpResponseData {
fun <T> respondJson(response: T, serializer: KSerializer<T>): MockEngine {
val responseString = JsonNoDefaults.stringify(serializer, response)
return MockEngine {
respond(
headers = headersOf(
"Content-Type",
listOf(ContentType.Application.Json.toString())
),
content = ByteReadChannel(responseString)
)
}
}

fun respondBadRequest(): ClientSearch {
val mockEngine = MockEngine {
respondBadRequest()
}
return ClientSearch(
ConfigurationSearch(
ApplicationID("A"),
APIKey("B"),
engine = mockEngine,
logLevel = LogLevel.ALL
)
)
}

val defaultMockEngine = MockEngine {
val responseString = JsonNoDefaults.stringify(ResponseSearch.serializer(), responseSearch)

return respond(
respond(
headers = headersOf(
"Content-Type",
listOf(ContentType.Application.Json.toString())
),
content = ByteReadChannel(responseString)
)
}
}

val responseSearch = ResponseSearch()
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import blocking
import com.algolia.search.model.Attribute
import com.algolia.search.model.IndexName
import com.algolia.search.model.response.ResponseSearchForFacets
import io.ktor.client.engine.mock.respondBadRequest
import mockClient
import respondBadRequest
import respondJson
import shouldBeFalse
import shouldBeNull
Expand All @@ -25,7 +25,7 @@ class TestSearcherForFacets {
)
private val client = mockClient(respondJson(response, ResponseSearchForFacets.serializer()))
private val index = client.initIndex(IndexName("index"))
private val clientError = mockClient(respondBadRequest())
private val clientError = respondBadRequest()
private val indexError = clientError.initIndex(IndexName("index"))

@Test
Expand Down
Loading

0 comments on commit 6fd4cce

Please sign in to comment.