Skip to content

Instantly share code, notes, and snippets.

View oleksiyp's full-sized avatar

Oleksiy Pylypenko oleksiyp

View GitHub Profile
@oleksiyp
oleksiyp / envoy-1.16.0.jsonschema
Created November 6, 2020 08:21
Envyo 1.16.0 schema
{
"$schema": "http://json-schema.org/draft-04/schema#",
"properties": {
"node": {
"properties": {
"id": {
"type": "string",
"description": "An opaque node identifier for the Envoy node. This also provides the local\n service node name. It should be set if any of the following features are\n used: :ref:`statsd \u003carch_overview_statistics\u003e`, :ref:`CDS\n \u003cconfig_cluster_manager_cds\u003e`, and :ref:`HTTP tracing\n \u003carch_overview_tracing\u003e`, either in this message or via\n :option:`--service-node`."
},
"cluster": {
Abc def
Abc def
@oleksiyp
oleksiyp / Channel$Subclass0-broken.txt
Created January 26, 2019 19:43
Classes produced by ByteBuddy when using subclass
Classfile /home/oleksiyp/workspace/playground-issue219/broken/Channel$Subclass0.class
Last modified Jan 26, 2019; size 5600 bytes
MD5 checksum 59659ef9d1918d11c3ee4ae1e4431de1
public class kotlinx.coroutines.channels.Channel$Subclass0 implements kotlinx.coroutines.channels.Channel
minor version: 0
major version: 54
flags: (0x0021) ACC_PUBLIC, ACC_SUPER
this_class: #2 // kotlinx/coroutines/channels/Channel$Subclass0
super_class: #4 // java/lang/Object
interfaces: 1, fields: 20, methods: 26, attributes: 1
@oleksiyp
oleksiyp / Coroutine.kt
Created November 2, 2018 18:53
"MockK: intentions" coroutines
coEvery { mock.suspendFn() } returns 5
@oleksiyp
oleksiyp / GenericFn.kt
Created November 2, 2018 18:45
"MockK: intentions" generic function
interface Cls {
fun <T>genericFn(): T
fun otherFn(param: Int) = param + 1
}
val mock = mockk<Cls>()
every {
mock.otherFn(mock.genericFn())
@oleksiyp
oleksiyp / ObjectMockK.kt
Created November 2, 2018 18:41
"MockK: intentions" object mock
object Obj {
fun objectFn() = 5
}
mockkObject(Obj)
every { Obj.objectFn() } returns 6
@oleksiyp
oleksiyp / StaticMockK.kt
Created November 2, 2018 18:38
"MockK: intentions" static mockk
// --- top level function ---
mockkStatic("pkg.FileKt")
every { topLevelFunctionInFileKt() } returns 5
// --- Java static function ---
mockkStatic(Uri::class)
every { Uri.parse("http://test/path") } returns Uri("http", "test", "path")
@oleksiyp
oleksiyp / ChainedCallsInKtor.kt
Created November 2, 2018 18:33
"MockK: intentions" chained calls
every {
route
.application
.attributes
.get(ApplicationFeature.registry)
.get(Locations.key)
} returns locations
@oleksiyp
oleksiyp / DefaultArgsOnCopy.kt
Created November 2, 2018 18:31
"MockK: intentions" data class copy
data class Entity(
val id: Int = 1,
val firstName: String = "John",
val lastName: String = "Smith",
val age: Int = 44
)
every {
entity.copy(
firstName = "Sam",
@oleksiyp
oleksiyp / DSLExamples.kt
Last active November 2, 2018 18:38
"MockK: intentions" DSL examples
// --- many chained calls ---
val presenter : LoginPresenter = spyk<LoginPresenter>()
val viewCallback = mockk<LoginContract.LoginViewCallBack>()
val cookieStore = mockk<PianoCookieStore>()
val loginRequest = LoginRequest("user", "pwd")
val customerResponse = CustomerResponse("j", "r")
every { presenter.accountDelegator.login(loginRequest) } returns Single.just(Response.success(any()))