Skip to content

Commit b80bc88

Browse files
committed
integration tests
Signed-off-by: clux <[email protected]>
1 parent a19f2f2 commit b80bc88

File tree

4 files changed

+29
-7
lines changed

4 files changed

+29
-7
lines changed

justfile

+8-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ default:
99
fmt:
1010
cargo +nightly fmt
1111

12-
test: test-pr test-sm test-mv test-argo test-agent test-certmanager test-cluster test-linkerd-serverauth test-linkerd-server
12+
test: test-pr test-sm test-mv test-argo test-agent test-certmanager test-cluster test-gateway-route test-linkerd-serverauth test-linkerd-server
1313

1414
test-pr:
1515
kubectl apply --force-conflicts --server-side -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.52.0/example/prometheus-operator-crd/monitoring.coreos.com_prometheusrules.yaml
@@ -60,6 +60,13 @@ test-cluster:
6060
# No test instance for this crd
6161
cargo build --test runner
6262

63+
test-gateway-route:
64+
kubectl apply --server-side -f tests/httproute-crd.yaml
65+
cargo run --bin kopium -- -f tests/httproute-crd.yaml > tests/gen.rs
66+
echo "pub type CR = HTTPRoute;" >> tests/gen.rs
67+
kubectl apply -f tests/httproute.yaml
68+
cargo test --test runner -- --nocapture
69+
6370
test-linkerd-serverauth:
6471
kubectl apply --server-side -f tests/serverauth-crd.yaml
6572
cargo run --bin kopium -- -d serverauthorizations.policy.linkerd.io > tests/gen.rs

src/analyzer.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ fn find_containers(
164164
x => {
165165
if let Some(en) = &value.enum_ {
166166
// plain enums do not need to recurse, can collect it here
167+
// ....although this makes it impossible for us to handle enums at the top level
168+
// TODO: move this to the top level
167169
let new_result = analyze_enum_properties(&en, &next_stack, level, &schema)?;
168170
results.push(new_result);
169171
} else {
@@ -933,7 +935,7 @@ type: object
933935

934936

935937
#[test]
936-
fn integer_enum_discriminants() {
938+
fn top_level_enum_with_integers() {
937939
init();
938940
let schema_str = r#"
939941
default: 302
@@ -952,11 +954,7 @@ type: object
952954
assert_eq!(root.is_enum, true);
953955
assert_eq!(&root.members[0].name, "r#_301");
954956
assert_eq!(&root.members[0].name, "r#_302");
955-
assert_eq!(
956-
&root.members[0].type_,
957-
"Option<Vec<HashMap<String, serde_json::Value>>>"
958-
);
959-
957+
assert_eq!(&root.members[0].type_, "");
960958
}
961959

962960
#[test]
File renamed without changes.

tests/httproute.yaml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
apiVersion: gateway.networking.k8s.io/v1beta1
3+
kind: HTTPRoute
4+
metadata:
5+
name: gen
6+
spec:
7+
parentRefs:
8+
- name: gateway
9+
namespace: istio-system
10+
sectionName: foobar
11+
- name: gateway
12+
namespace: istio-system
13+
sectionName: same-namespace
14+
rules:
15+
- backendRefs:
16+
- name: httpbin
17+
port: 81

0 commit comments

Comments
 (0)