Skip to content

Commit

Permalink
Add helm unittesting scaffolds
Browse files Browse the repository at this point in the history
  • Loading branch information
dbkegley committed Oct 30, 2024
1 parent 884427b commit c2183e6
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/chart-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,28 @@ jobs:
if: steps.ct-lint.outcome == 'failure' || steps.ct-lint-all.outcome == 'failure'
run: exit 1

test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Helm
uses: azure/[email protected]
with:
version: v3.6.3

- name: Install helm unittest plugin
run: helm plugin install --version v0.6.3 https://github.com/helm-unittest/helm-unittest.git

- name: Run chart unit tests
run: |
for dir in $(ls -d charts/*/); do
helm unittest $dir
done
install:
runs-on: ubuntu-latest
steps:
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ helm-docs
charts/**/charts/
/*.values
/.cr-release-packages

# helm unittest plugin
__snapshot__

bin/**
!bin/README.md

Expand All @@ -10,3 +14,4 @@ _site/
_publish.yml

/.quarto/

13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ We'll try to be as responsive as possible in reviewing and accepting pull reques
- If `index.yaml` gets out of date on the repository, see
[`./scripts/`](./scripts) for a workflow to fix

## Testing

Running the [helm chart unit tests](https://github.com/helm-unittest/helm-unittest):

```
# install the unittest plugin
helm plugin install https://github.com/helm-unittest/helm-unittest.git
# run the rstudio-connect chart unittests
# unit tests are defined in `charts/$CHART_NAME/tests`
helm unittest --color ./charts/rstudio-connect
```

## Templates

The `rstudio-workbench` and `rstudio-connect` charts both make heavy use of the "templating" feature of the Posit Job
Expand Down
32 changes: 32 additions & 0 deletions charts/rstudio-connect/tests/service-accounts_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
suite: Connect Service Accounts
templates:
- configmap.yaml
- configmap-prestart.yaml
- deployment.yaml
tests:
- it: should set the Connect pod service account when the launcher is enabled
template: deployment.yaml
set:
launcher:
enabled: true
rbac:
create: true
serviceAccount:
name: "connect-service-account"
asserts:
- equal:
path: "spec.template.spec.serviceAccountName"
value: "connect-service-account"
- it: should set the Connect pod service account when the launcher is not enabled
template: deployment.yaml
set:
launcher:
enabled: false
rbac:
create: true
serviceAccount:
name: "connect-service-account"
asserts:
- equal:
path: "spec.template.spec.serviceAccountName"
value: "connect-service-account"

0 comments on commit c2183e6

Please sign in to comment.