Skip to content

Commit e807ab9

Browse files
committed
test(wkt): integration tests use generated types
Use generated types for the custom encoding / decoding of primitive types. This makes the tests more realistic. This change uses `include!()` because it needed to inject an alias for `wkt` and changing the generator seemed hard. Unfortunately this also means the generated code is recompiled in each test, I think we can fix that later if it becomes annoying. It does not affect customers as it is isolated to tests. The generator changes and the corresponding changes in the generated code are to support overrides in the `#![allow(...)]` attributes. I needed to set them for this module, and they were hard-coded in `mod.rs.mustache` (but not other templates).
1 parent 441aa4c commit e807ab9

File tree

16 files changed

+747
-277
lines changed

16 files changed

+747
-277
lines changed

generator/internal/rust/codec.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,11 @@ func newCodec(protobufSource bool, options map[string]string) (*codec, error) {
111111
codec.packageMapping[source] = pkgOption.pkg
112112
}
113113
case key == "disabled-rustdoc-warnings":
114-
codec.disabledRustdocWarnings = strings.Split(definition, ",")
114+
if definition == "" {
115+
codec.disabledRustdocWarnings = []string{}
116+
} else {
117+
codec.disabledRustdocWarnings = strings.Split(definition, ",")
118+
}
115119
case key == "template-override":
116120
codec.templateOverride = definition
117121
case key == "include-grpc-only-methods":

generator/internal/rust/templates/mod/mod.rs.mustache

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ limitations under the License.
1818
//{{{.}}}
1919
{{/Codec.BoilerPlate}}
2020

21-
{{! Google APIs often use angle brackets for <PLACEHOLDERS>, rustdoc does not like those. }}
22-
#![allow(rustdoc::invalid_html_tags)]
23-
{{! We use explicit links because it is easier to generate the code with them. }}
24-
#![allow(rustdoc::redundant_explicit_links)]
21+
{{#Codec.DisabledRustdocWarnings}}
22+
#![allow(rustdoc::{{.}})]
23+
{{/Codec.DisabledRustdocWarnings}}
2524
{{#Codec.IsWktCrate}}
2625
{{!
2726
This file is used to bootstrap the `google-cloud-wkt` crate. In all other crates

src/firestore/src/generated/gapic/model.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
//
1515
// Code generated by sidekick. DO NOT EDIT.
1616

17-
#![allow(rustdoc::invalid_html_tags)]
1817
#![allow(rustdoc::redundant_explicit_links)]
18+
#![allow(rustdoc::broken_intra_doc_links)]
1919

2020
/// The result of a single bucket from a Firestore aggregation query.
2121
///

src/protojson-conformance/src/generated/gapic/model.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
//
1515
// Code generated by sidekick. DO NOT EDIT.
1616

17-
#![allow(rustdoc::invalid_html_tags)]
1817
#![allow(rustdoc::redundant_explicit_links)]
18+
#![allow(rustdoc::broken_intra_doc_links)]
1919

2020
/// Meant to encapsulate all types of tests: successes, skips, failures, etc.
2121
/// Therefore, this may or may not have a failure message. Failure messages

src/protojson-conformance/src/generated/test_protos/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
//
1515
// Code generated by sidekick. DO NOT EDIT.
1616

17-
#![allow(rustdoc::invalid_html_tags)]
1817
#![allow(rustdoc::redundant_explicit_links)]
18+
#![allow(rustdoc::broken_intra_doc_links)]
1919

2020
/// This proto includes every type of field in both singular and repeated
2121
/// forms.

src/storage-control/src/generated/gapic/model.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
//
1515
// Code generated by sidekick. DO NOT EDIT.
1616

17-
#![allow(rustdoc::invalid_html_tags)]
1817
#![allow(rustdoc::redundant_explicit_links)]
18+
#![allow(rustdoc::broken_intra_doc_links)]
1919

2020
/// Request message for DeleteBucket.
2121
#[serde_with::serde_as]

src/storage-control/src/generated/gapic_control/model.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
//
1515
// Code generated by sidekick. DO NOT EDIT.
1616

17-
#![allow(rustdoc::invalid_html_tags)]
1817
#![allow(rustdoc::redundant_explicit_links)]
18+
#![allow(rustdoc::broken_intra_doc_links)]
1919

2020
/// Contains information about a pending rename operation.
2121
#[serde_with::serde_as]

src/wkt/src/generated/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
//
1515
// Code generated by sidekick. DO NOT EDIT.
1616

17-
#![allow(rustdoc::invalid_html_tags)]
1817
#![allow(rustdoc::redundant_explicit_links)]
18+
#![allow(rustdoc::broken_intra_doc_links)]
1919
use crate as wkt;
2020

2121
/// Api is a light-weight descriptor for an API Interface.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
[general]
16+
specification-source = 'src/wkt/tests/generated'
17+
18+
[source]
19+
roots = 'project'
20+
project-root = '.'
21+
22+
[codec]
23+
copyright-year = '2025'
24+
template-override = 'templates/mod'
25+
module-path = 'crate::protos'
26+
disabled-rustdoc-warnings = ''

0 commit comments

Comments
 (0)