|
| 1 | +/* |
| 2 | + * Copyright 2025 Google LLC |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package com.google.firebase.dataconnect.connectors.demo |
| 17 | + |
| 18 | +import com.google.firebase.dataconnect.connectors.demo.testutil.DemoConnectorIntegrationTestBase |
| 19 | +import com.google.firebase.dataconnect.testutil.property.arbitrary.dataConnect |
| 20 | +import io.kotest.assertions.withClue |
| 21 | +import io.kotest.matchers.nulls.shouldNotBeNull |
| 22 | +import io.kotest.matchers.shouldBe |
| 23 | +import io.kotest.property.Arb |
| 24 | +import io.kotest.property.arbitrary.next |
| 25 | +import kotlinx.coroutines.test.runTest |
| 26 | +import org.junit.Test |
| 27 | + |
| 28 | +class EmptySelectionSetIntegrationTest : DemoConnectorIntegrationTestBase() { |
| 29 | + |
| 30 | + @Test |
| 31 | + fun queryWithEmptySelectionSet() = runTest { |
| 32 | + val id = Arb.dataConnect.id().next(rs) |
| 33 | + val queryResult = connector.getFooByIdEmptySelectionSet.execute(id) |
| 34 | + queryResult.data shouldBe Unit |
| 35 | + } |
| 36 | + |
| 37 | + @Test |
| 38 | + fun mutationWithEmptySelectionSet() = runTest { |
| 39 | + val id = Arb.dataConnect.id().next(rs) |
| 40 | + val barValue = "bar" + Arb.dataConnect.id().next(rs) |
| 41 | + |
| 42 | + val mutationResult = connector.upsertFooEmptySelectionSet.execute(id) { bar = barValue } |
| 43 | + |
| 44 | + withClue("mutationResult.data") { mutationResult.data shouldBe Unit } |
| 45 | + val foo = withClue("getFooById") { connector.getFooById.execute(id).data.foo.shouldNotBeNull() } |
| 46 | + withClue("foo.bar") { foo.bar shouldBe barValue } |
| 47 | + } |
| 48 | +} |
0 commit comments