-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-introduce default generic for server service struct
- Loading branch information
1 parent
0f9ada6
commit a30baba
Showing
2 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
39 changes: 39 additions & 0 deletions
39
...oftware/amazon/smithy/rust/codegen/server/smithy/generators/ServerServiceGeneratorTest.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package software.amazon.smithy.rust.codegen.server.smithy.generators | ||
|
||
import org.junit.jupiter.api.Test | ||
import software.amazon.smithy.rust.codegen.core.rustlang.rust | ||
import software.amazon.smithy.rust.codegen.core.testutil.asSmithyModel | ||
import software.amazon.smithy.rust.codegen.core.testutil.testModule | ||
import software.amazon.smithy.rust.codegen.server.smithy.testutil.serverIntegrationTest | ||
import java.io.File | ||
|
||
internal class ServerServiceGeneratorTest { | ||
/** | ||
* See <https://github.com/smithy-lang/smithy-rs/issues/3177>. | ||
*/ | ||
@Test | ||
fun `one should be able to return a built service from a function`() { | ||
val model = File("../codegen-core/common-test-models/simple.smithy").readText().asSmithyModel() | ||
|
||
serverIntegrationTest(model) { _, rustCrate -> | ||
rustCrate.testModule { | ||
// No actual tests: we just want to check that this compiles. | ||
rust( | ||
""" | ||
fn _build_service() -> crate::SimpleService { | ||
let config = crate::SimpleServiceConfig::builder().build(); | ||
let service = crate::SimpleService::builder(config).build_unchecked(); | ||
service.boxed() | ||
} | ||
""" | ||
) | ||
} | ||
} | ||
} | ||
} |