Skip to content

Commit

Permalink
test(generator): golden files for openapi (#66)
Browse files Browse the repository at this point in the history
This introduces (incomplete, not usable) golden files for the openapi branch of
the generator. I decided to just regenerate the golden files on each run, and
then let `git diff` detect any changes.
  • Loading branch information
coryan authored Nov 3, 2024
1 parent 97e05e6 commit bbddb19
Show file tree
Hide file tree
Showing 5 changed files with 1,024 additions and 61 deletions.
19 changes: 0 additions & 19 deletions generator/Makefile

This file was deleted.

32 changes: 32 additions & 0 deletions generator/cmd/openapi/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package main

import (
"flag"
"os"
"testing"
)

func TestMain(m *testing.M) {
flag.Parse()
os.Exit(m.Run())
}

func TestRun_Rust(t *testing.T) {
if err := run("testdata/secretmanager_openapi_v1.json", "rust", "testdata/rust/golden", "../../templates"); err != nil {
t.Fatal(err)
}
}
28 changes: 28 additions & 0 deletions generator/cmd/openapi/testdata/rust/golden/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use std::sync::Arc;

pub mod model;

#[derive(Clone, Debug)]
pub struct Client {
inner: Arc<ClientRef>,
}

#[derive(Debug)]
struct ClientRef {
http_client: reqwest::Client,
token: String,
}

impl Client {
pub fn new(tok: String) -> Self {
let client = reqwest::Client::builder().build().unwrap();
let inner = ClientRef {
http_client: client,
token: tok,
};
Self {
inner: Arc::new(inner),
}
}
}

Loading

0 comments on commit bbddb19

Please sign in to comment.