Skip to content

Commit 5d2110c

Browse files
committed
Fix doctests for protobuf 3.x API and add integration test docs
- Update MutateRow, MutateRows, CheckAndMutateRow doctests to use protobuf 3.x oneof enum variant syntax instead of field assignment - Add integration testing section to CLAUDE.md with GCP project details - Add *.json to .gitignore to protect credentials
1 parent d8c72d0 commit 5d2110c

4 files changed

Lines changed: 48 additions & 14 deletions

File tree

.beads/issues.jsonl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{"id":"rust-bigtable-30c","title":"Fix doctests for protobuf 3.x API","description":"Why: 3 doctests fail - MutateRow, MutateRows, CheckAndMutateRow use old delete_from_row field syntax instead of mutation oneof. Done when: cargo test -- --ignored passes.","status":"closed","priority":1,"issue_type":"bug","created_at":"2025-12-10T00:10:09.897449+01:00","updated_at":"2025-12-10T00:12:18.386935+01:00","closed_at":"2025-12-10T00:12:18.386935+01:00","close_reason":"Fixed 3 doctests for protobuf 3.x API compatibility"}
12
{"id":"rust-bigtable-3qg","title":"Update protobuf API usage (RepeatedField -\u003e Vec, getter changes)","description":"Why: protobuf 3.x removed RepeatedField, changed getter prefixes. Done when: all src files use Vec and new getter names.","status":"closed","priority":1,"issue_type":"task","created_at":"2025-12-09T23:19:20.609494+01:00","updated_at":"2025-12-09T23:25:32.573329+01:00","closed_at":"2025-12-09T23:25:32.573329+01:00","close_reason":"Updated protobuf API: RepeatedField-\u003eVec, MessageFull trait, direct field access","dependencies":[{"issue_id":"rust-bigtable-3qg","depends_on_id":"rust-bigtable-nko","type":"blocks","created_at":"2025-12-09T23:20:08.478991+01:00","created_by":"daemon"},{"issue_id":"rust-bigtable-3qg","depends_on_id":"rust-bigtable-k8t","type":"blocks","created_at":"2025-12-09T23:20:16.756889+01:00","created_by":"daemon"}]}
23
{"id":"rust-bigtable-6u0","title":"Update goauth API (get_token_with_creds -\u003e get_token_blocking)","description":"Why: goauth 0.17 renamed token retrieval function. Done when: utils.rs uses get_token_blocking or async get_token.","status":"closed","priority":1,"issue_type":"task","created_at":"2025-12-09T23:19:33.88726+01:00","updated_at":"2025-12-09T23:23:20.639651+01:00","closed_at":"2025-12-09T23:23:20.639651+01:00","close_reason":"Updated get_token_with_creds to get_token_blocking","dependencies":[{"issue_id":"rust-bigtable-6u0","depends_on_id":"rust-bigtable-nko","type":"blocks","created_at":"2025-12-09T23:20:08.546442+01:00","created_by":"daemon"}]}
34
{"id":"rust-bigtable-i1x","title":"Replace rustc-serialize with base64 crate","description":"Why: rustc-serialize is deprecated. Done when: base64 encoding uses base64 crate, rustc-serialize removed from deps.","status":"closed","priority":1,"issue_type":"task","created_at":"2025-12-09T23:19:10.820357+01:00","updated_at":"2025-12-09T23:23:20.610896+01:00","closed_at":"2025-12-09T23:23:20.610896+01:00","close_reason":"Replaced rustc_serialize::base64 with base64 crate","dependencies":[{"issue_id":"rust-bigtable-i1x","depends_on_id":"rust-bigtable-nko","type":"blocks","created_at":"2025-12-09T23:20:08.445798+01:00","created_by":"daemon"}]}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@ Cargo.lock
33
/pk.pem
44
.idea*
55
src/protos
6+
7+
# Credentials - never commit
8+
*.json
9+
!dummy_credentials_file_for_tests.json

CLAUDE.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,35 @@ cargo check
5252

5353
### Dependencies
5454
- `goauth` / `smpl_jwt`: Google OAuth2 / JWT authentication
55-
- `protobuf` / `protobuf-json-temp`: Protobuf message handling and JSON conversion
55+
- `protobuf` / `protobuf-json-mapping`: Protobuf message handling and JSON conversion
5656
- `curl`: HTTP client
5757
- `serde_json`: JSON serialization
58+
59+
## Integration Testing
60+
61+
### GCP Resources
62+
- **Project ID**: `gen-lang-client-0421059902`
63+
- **Instance**: `test-inst`
64+
- **Table**: `my-table`
65+
- **Column Family**: `cf1`
66+
67+
### Setup Commands
68+
```bash
69+
# Create instance
70+
gcloud bigtable instances create test-inst \
71+
--project=gen-lang-client-0421059902 \
72+
--cluster=test-cluster \
73+
--cluster-zone=us-central1-c \
74+
--display-name="Test Instance"
75+
76+
# Create table with column family
77+
cbt -project=gen-lang-client-0421059902 -instance=test-inst createtable my-table
78+
cbt -project=gen-lang-client-0421059902 -instance=test-inst createfamily my-table cf1
79+
```
80+
81+
### Credentials
82+
Requires a service account JSON key with `roles/bigtable.user` permission.
83+
- **Credentials file**: `Rust Bigtable IAM Admin.json` (gitignored)
84+
- **Service account**: `rustbigtable@gen-lang-client-0421059902.iam.gserviceaccount.com`
85+
86+
Usage: `get_auth_token("Rust Bigtable IAM Admin.json", true)`

src/method.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ method!(SampleRowKeys, SampleRowKeysRequest, false);
120120
/// use bt::request::BTRequest;
121121
/// use bt::utils::*;
122122
/// use bt::method::{BigTable, MutateRow};
123-
/// use bt::protos::data::Mutation;
123+
/// use bt::protos::data::{Mutation, mutation};
124124
/// use bt::error::BTErr;
125125
///
126126
/// fn wrapper() -> Result<(), BTErr> {
@@ -132,11 +132,11 @@ method!(SampleRowKeys, SampleRowKeysRequest, false);
132132
///
133133
/// let row_key = encode_str("r1");
134134
///
135-
/// let mut mutation = Mutation::new();
136-
/// mutation.delete_from_row = Some(Default::default()).into();
135+
/// let mut m = Mutation::new();
136+
/// m.mutation = Some(mutation::Mutation::DeleteFromRow(Default::default()));
137137
///
138138
/// req.method.payload_mut().row_key = row_key;
139-
/// req.method.payload_mut().mutations.push(mutation);
139+
/// req.method.payload_mut().mutations.push(m);
140140
///
141141
/// let response = req.execute(&get_auth_token("credentials.json", true)?)?;
142142
/// println!("{}", serde_json::to_string_pretty(&response)?);
@@ -153,7 +153,7 @@ method!(MutateRow, MutateRowRequest, true);
153153
/// use bt::request::BTRequest;
154154
/// use bt::utils::*;
155155
/// use bt::method::{BigTable, MutateRows};
156-
/// use bt::protos::data::Mutation;
156+
/// use bt::protos::data::{Mutation, mutation};
157157
/// use bt::protos::bigtable::mutate_rows_request;
158158
/// use bt::error::BTErr;
159159
///
@@ -166,12 +166,12 @@ method!(MutateRow, MutateRowRequest, true);
166166
///
167167
/// let row_key = encode_str("r1");
168168
///
169-
/// let mut mutation = Mutation::new();
170-
/// mutation.delete_from_row = Some(Default::default()).into();
169+
/// let mut m = Mutation::new();
170+
/// m.mutation = Some(mutation::Mutation::DeleteFromRow(Default::default()));
171171
///
172172
/// let mut entry = mutate_rows_request::Entry::new();
173173
/// entry.row_key = row_key;
174-
/// entry.mutations.push(mutation);
174+
/// entry.mutations.push(m);
175175
///
176176
/// req.method.payload_mut().entries.push(entry);
177177
///
@@ -190,7 +190,7 @@ method!(MutateRows, MutateRowsRequest, true);
190190
/// use bt::request::BTRequest;
191191
/// use bt::utils::*;
192192
/// use bt::method::{BigTable, CheckAndMutateRow};
193-
/// use bt::protos::data::{RowFilter, Mutation};
193+
/// use bt::protos::data::{RowFilter, Mutation, mutation, row_filter};
194194
/// use bt::error::BTErr;
195195
///
196196
/// fn wrapper() -> Result<(), BTErr> {
@@ -203,14 +203,14 @@ method!(MutateRows, MutateRowsRequest, true);
203203
/// let row_key = encode_str("r1");
204204
///
205205
/// let mut predicate_filter = RowFilter::new();
206-
/// predicate_filter.set_pass_all_filter(true);
206+
/// predicate_filter.filter = Some(row_filter::Filter::PassAllFilter(true));
207207
///
208-
/// let mut mutation = Mutation::new();
209-
/// mutation.delete_from_row = Some(Default::default()).into();
208+
/// let mut m = Mutation::new();
209+
/// m.mutation = Some(mutation::Mutation::DeleteFromRow(Default::default()));
210210
///
211211
/// req.method.payload_mut().row_key = row_key;
212212
/// req.method.payload_mut().predicate_filter = Some(predicate_filter).into();
213-
/// req.method.payload_mut().true_mutations.push(mutation);
213+
/// req.method.payload_mut().true_mutations.push(m);
214214
///
215215
/// let response = req.execute(&get_auth_token("credentials.json", true)?)?;
216216
/// println!("{}", serde_json::to_string_pretty(&response)?);

0 commit comments

Comments
 (0)