From 937f6f4bc9b9059f703fe39665b326d98e440f15 Mon Sep 17 00:00:00 2001 From: Bill Franklin Date: Fri, 15 Jul 2022 11:39:15 +0100 Subject: [PATCH] Add acceptance tests for duplicated properties --- acceptance.bats | 10 ++++++++++ fixtures/duplicate_property.yaml | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 fixtures/duplicate_property.yaml diff --git a/acceptance.bats b/acceptance.bats index f8ec232..fde5999 100755 --- a/acceptance.bats +++ b/acceptance.bats @@ -138,6 +138,16 @@ resetCacheFolder() { [ "$status" -eq 1 ] } +@test "Fail when parsing a config with duplicate properties and strict set" { + run bin/kubeconform -strict -kubernetes-version 1.16.0 fixtures/duplicate_property.yaml + [ "$status" -eq 1 ] +} + +@test "Pass when parsing a config with duplicate properties and strict NOT set" { + run bin/kubeconform -kubernetes-version 1.16.0 fixtures/duplicate_property.yaml + [ "$status" -eq 0 ] +} + @test "Pass when using a valid, preset -schema-location" { run bin/kubeconform -schema-location default fixtures/valid.yaml [ "$status" -eq 0 ] diff --git a/fixtures/duplicate_property.yaml b/fixtures/duplicate_property.yaml new file mode 100644 index 0000000..322c145 --- /dev/null +++ b/fixtures/duplicate_property.yaml @@ -0,0 +1,18 @@ +--- +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: nginx-ds +spec: + replicas: 2 + selector: + matchLabels: + k8s-app: nginx-ds + template: + spec: + containers: + - image: envoy + name: envoy + containers: + - image: nginx + name: nginx