Skip to content

Commit

Permalink
adapt tests to apiextensions.k8s.io/v1
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Ruoss committed Aug 31, 2022
1 parent 0526a0b commit 56041c3
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 18 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Updated

- Use name of application in Deployments instead of service account name.
- Use name of application in Deployments instead of service account name. ([#142](https://github.com/coryodaniel/bonny/pull/142))

### Fixed

Expand Down
4 changes: 2 additions & 2 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ if Mix.env() == :test do
http_provider: K8s.Client.DynamicHTTPProvider

config :bonny,
controllers: [Widget, Cog],
controllers: [Widget, Cog, Whizbang],
group: "example.com",
get_conn: {Bonny.K8sMock, :conn},
api_version: "apiextensions.k8s.io/v1beta1"
api_version: "apiextensions.k8s.io/v1"
end

if Mix.env() == :dev do
Expand Down
71 changes: 56 additions & 15 deletions test/bonny/operator_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ defmodule Bonny.OperatorTest do
},
%{apiGroups: ["example.com"], resources: ["widgets"], verbs: ["*"]},
%{apiGroups: ["example.com"], resources: ["cogs"], verbs: ["*"]},
%{apiGroups: ["example.com"], resources: ["whizbangs"], verbs: ["*"]},
%{apiGroups: ["apps"], resources: ["deployments", "services"], verbs: ["*"]},
%{apiGroups: [""], resources: ["configmaps"], verbs: ["create", "read"]}
]
Expand All @@ -37,6 +38,7 @@ defmodule Bonny.OperatorTest do
},
%{apiGroups: ["example.com"], resources: ["widgets"], verbs: ["*"]},
%{apiGroups: ["example.com"], resources: ["cogs"], verbs: ["*"]},
%{apiGroups: ["example.com"], resources: ["whizbangs"], verbs: ["*"]},
%{apiGroups: ["apps"], resources: ["deployments", "services"], verbs: ["*"]},
%{apiGroups: [""], resources: ["configmaps"], verbs: ["create", "read"]}
]
Expand All @@ -61,36 +63,75 @@ defmodule Bonny.OperatorTest do

expected = [
%{
apiVersion: "apiextensions.k8s.io/v1beta1",
apiVersion: "apiextensions.k8s.io/v1",
kind: "CustomResourceDefinition",
metadata: %{labels: %{"k8s-app" => "bonny"}, name: "widgets.example.com"},
spec: %{
additionalPrinterColumns: [
%{JSONPath: ".spec.test", description: "test", name: "test", type: "string"},
%{
JSONPath: ".metadata.creationTimestamp",
description:
"CreationTimestamp is a timestamp representing the server time when this object was created. It is not guaranteed to be set in happens-before order across separate operations. Clients may not set this value. It is represented in RFC3339 form and is in UTC.\n\n Populated by the system. Read-only. Null for lists. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata",
name: "Age",
type: "date"
}
],
group: "example.com",
names: %{kind: "Widget", plural: "widgets", shortNames: nil, singular: "widget"},
scope: "Namespaced",
version: "v1"
versions: [
%{
additionalPrinterColumns: [
%{description: "test", jsonPath: ".spec.test", name: "test", type: "string"},
%{
description:
"CreationTimestamp is a timestamp representing the server time when this object was created. It is not guaranteed to be set in happens-before order across separate operations. Clients may not set this value. It is represented in RFC3339 form and is in UTC.\n\n Populated by the system. Read-only. Null for lists. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata",
jsonPath: ".metadata.creationTimestamp",
name: "Age",
type: "date"
}
],
name: "v1",
schema: %{
openAPIV3Schema: %{type: "object", "x-kubernetes-preserve-unknown-fields": true}
},
served: true,
storage: true
}
]
}
},
%{
apiVersion: "apiextensions.k8s.io/v1beta1",
apiVersion: "apiextensions.k8s.io/v1",
kind: "CustomResourceDefinition",
metadata: %{labels: %{"k8s-app" => "bonny"}, name: "cogs.example.com"},
spec: %{
additionalPrinterColumns: [],
group: "example.com",
names: %{kind: "Cog", plural: "cogs", shortNames: nil, singular: "cog"},
scope: "Namespaced",
version: "v1"
versions: [
%{
additionalPrinterColumns: [],
name: "v1",
schema: %{
openAPIV3Schema: %{type: "object", "x-kubernetes-preserve-unknown-fields": true}
},
served: true,
storage: true
}
]
}
},
%{
apiVersion: "apiextensions.k8s.io/v1",
kind: "CustomResourceDefinition",
metadata: %{labels: %{"k8s-app" => "bonny"}, name: "whizbangs.example.com"},
spec: %{
group: "example.com",
names: %{kind: "Whizbang", plural: "whizbangs", shortNames: nil, singular: "whizbang"},
scope: "Namespaced",
versions: [
%{
additionalPrinterColumns: [],
name: "v1",
schema: %{
openAPIV3Schema: %{type: "object", "x-kubernetes-preserve-unknown-fields": true}
},
served: true,
storage: true
}
]
}
}
]
Expand Down

0 comments on commit 56041c3

Please sign in to comment.