Change how we test DnsOverHttps#9549
Conversation
Rather than returning opaque hard-coded response bodies, use our new message encoder so we can test with real value objects.
| @@ -79,75 +85,68 @@ class DnsOverHttpsTest { | |||
|
|
|||
| @Test | |||
| fun getOne() { | |||
There was a problem hiding this comment.
The previous opaque hex values made it difficult to tell that the query was for google.com and the result was for star.c10r.facebook.com.
In a forthcoming PR I’ll replace both with lysine.dev
There was a problem hiding this comment.
(It was a bug that the query and result domain names didn’t match)
| @RequiresOptIn(level = ERROR, message = "Internal APIs for OkHttp's own modules") | ||
| @Retention(BINARY) | ||
| @Target(CLASS, FUNCTION, PROPERTY) | ||
| annotation class OkHttpInternalApi |
There was a problem hiding this comment.
Keen to hear feedback on this thing I’m sneaking in
There was a problem hiding this comment.
Seems fine until https://github.com/Kotlin/KEEP/blob/main/proposals/KEEP-0451-shared-internals.md. Just so long as we remember to ensure they're all hidden from Java.
| @RequiresOptIn(level = ERROR, message = "Internal APIs for OkHttp's own modules") | ||
| @Retention(BINARY) | ||
| @Target(CLASS, FUNCTION, PROPERTY) | ||
| annotation class OkHttpInternalApi |
There was a problem hiding this comment.
Seems fine until https://github.com/Kotlin/KEEP/blob/main/proposals/KEEP-0451-shared-internals.md. Just so long as we remember to ensure they're all hidden from Java.
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| @file:OptIn(OkHttpInternalApi::class) |
There was a problem hiding this comment.
Alternately we could enable it module-wide in the compiler options
There was a problem hiding this comment.
Yep, coming up.
| */ | ||
| internal tailrec fun <T> AtomicReference<T>.testAndSet( | ||
| @OkHttpInternalApi | ||
| tailrec fun <T> AtomicReference<T>.testAndSet( |
There was a problem hiding this comment.
We could also just copy since it's small.
| /** | ||
| * Handles DNS calls using in-memory records. | ||
| */ | ||
| internal class DnsOverHttpsServer : Dispatcher() { |
Rather than returning opaque hard-coded response bodies, use our new message encoder so we can test with real value objects.