Created
June 19, 2020 12:47
-
-
Save guilhermekrz/9975ac66ec6e7b6bd5c36e71fc9532e2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
fun `test multiple calls to method which created OkHttpClient`() { | |
val kotlinFile = kotlin( | |
""" | |
package com.brokoli.lint | |
import okhttp3.OkHttpClient | |
class MyClass { | |
fun method1() { | |
OkHttpClient() | |
} | |
fun method2() { | |
method1() | |
} | |
fun method3() { | |
method1() | |
} | |
} | |
""" | |
).indented() | |
val lintResult = lint() | |
.files(okHttpClientFile, kotlinFile) | |
.run() | |
lintResult | |
.expectWarningCount(2) | |
.expect(""" | |
src/com/brokoli/lint/MyClass.kt:11: Warning: You should only create one OkHttpClient instance [MoreThanOneOkHttpClientDetector] | |
fun method2() { | |
^ | |
src/com/brokoli/lint/MyClass.kt:15: Warning: You should only create one OkHttpClient instance [MoreThanOneOkHttpClientDetector] | |
fun method3() { | |
^ | |
0 errors, 2 warnings | |
""".trimIndent()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment