Skip to content

Commit 3f2182a

Browse files
committed
fix: remove var env dependency by moving tests
1 parent 913cc49 commit 3f2182a

File tree

8 files changed

+396
-13
lines changed

8 files changed

+396
-13
lines changed

pkg/helm/chart_info_test.go

+5-13
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"github.com/norwoodj/helm-docs/pkg/helm"
55
"github.com/spf13/viper"
66
"github.com/stretchr/testify/suite"
7-
"os"
87
"path/filepath"
98
"regexp"
109
"testing"
@@ -18,27 +17,20 @@ func (_ *ChartParsingTestSuite) SetupTest() {
1817
viper.Set("values-file", "values.yaml")
1918
}
2019

21-
func (suite *ChartParsingTestSuite) resolveRelativePath(chartPath string) string {
22-
projectRoot := os.Getenv("PROJECT_ROOT")
23-
if projectRoot == "" {
24-
suite.T().Fatal("PROJECT_ROOT environment variable is not set")
25-
}
26-
return filepath.Join(projectRoot, chartPath)
27-
}
2820
func TestChartParsingTestSuite(t *testing.T) {
2921
suite.Run(t, new(ChartParsingTestSuite))
3022
}
3123

3224
func (suite *ChartParsingTestSuite) TestNotFullyDocumentedChartStrictModeOff() {
33-
chartPath := suite.resolveRelativePath("example-charts/full-template/")
25+
chartPath := filepath.Join("test-fixtures", "full-template")
3426
_, err := helm.ParseChartInformation(chartPath, helm.ChartValuesDocumentationParsingConfig{
3527
StrictMode: false,
3628
})
3729
suite.NoError(err)
3830
}
3931

4032
func (suite *ChartParsingTestSuite) TestNotFullyDocumentedChartStrictModeOn() {
41-
chartPath := suite.resolveRelativePath("example-charts/full-template/")
33+
chartPath := filepath.Join("test-fixtures", "full-template")
4234
_, err := helm.ParseChartInformation(chartPath, helm.ChartValuesDocumentationParsingConfig{
4335
StrictMode: true,
4436
})
@@ -61,7 +53,7 @@ controller.service.type`
6153
}
6254

6355
func (suite *ChartParsingTestSuite) TestNotFullyDocumentedChartStrictModeOnIgnores() {
64-
chartPath := suite.resolveRelativePath("example-charts/full-template/")
56+
chartPath := filepath.Join("test-fixtures", "full-template")
6557
_, err := helm.ParseChartInformation(chartPath, helm.ChartValuesDocumentationParsingConfig{
6658
StrictMode: true,
6759
AllowedMissingValuePaths: []string{
@@ -85,7 +77,7 @@ func (suite *ChartParsingTestSuite) TestNotFullyDocumentedChartStrictModeOnIgnor
8577
}
8678

8779
func (suite *ChartParsingTestSuite) TestNotFullyDocumentedChartStrictModeOnIgnoresRegexp() {
88-
chartPath := suite.resolveRelativePath("example-charts/full-template/")
80+
chartPath := filepath.Join("test-fixtures", "full-template")
8981
_, err := helm.ParseChartInformation(chartPath, helm.ChartValuesDocumentationParsingConfig{
9082
StrictMode: true,
9183
AllowedMissingValueRegexps: []*regexp.Regexp{
@@ -96,7 +88,7 @@ func (suite *ChartParsingTestSuite) TestNotFullyDocumentedChartStrictModeOnIgnor
9688
}
9789

9890
func (suite *ChartParsingTestSuite) TestFullyDocumentedChartStrictModeOn() {
99-
chartPath := suite.resolveRelativePath("example-charts/fully-documented/")
91+
chartPath := filepath.Join("test-fixtures", "fully-documented")
10092
_, err := helm.ParseChartInformation(chartPath, helm.ChartValuesDocumentationParsingConfig{
10193
StrictMode: true,
10294
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: v2
2+
name: full-template
3+
deprecated: true
4+
version: "1.0.0"
5+
type: application
6+
appVersion: "13.0.0"
7+
description: A chart for showing every README-element
8+
home: "https://github.com/norwoodj/helm-docs/tree/master/example-charts/full-template"
9+
maintainers:
10+
11+
name: John Norwood
12+
sources: ["https://github.com/norwoodj/helm-docs/tree/master/example-charts/full-template"]
13+
kubeVersion: "<=1.18"
14+
engine: gotpl
15+
16+
dependencies:
17+
- name: nginx-ingress
18+
version: "0.22.1"
19+
repository: "@stable"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
# full-template
2+
3+
## `extra.flower`
4+
```
5+
,-.
6+
, ,-. ,-.
7+
/ \ ( )-( )
8+
\ | ,.>-( )-<
9+
\|,' ( )-( )
10+
Y ___`-' `-'
11+
|/__/ `-'
12+
|
13+
|
14+
| -hi-
15+
__|_____________
16+
```
17+
18+
## `chart.deprecationWarning`
19+
> **:exclamation: This Helm Chart is deprecated!**
20+
21+
## `chart.name`
22+
23+
full-template
24+
25+
## `chart.description`
26+
27+
A chart for showing every README-element
28+
29+
## `chart.version`
30+
31+
1.0.0
32+
33+
## `chart.versionBadge`
34+
35+
![Version: 1.0.0](https://img.shields.io/badge/Version-1.0.0-informational?style=flat-square)
36+
37+
## `chart.type`
38+
39+
application
40+
41+
## `chart.typeBadge`
42+
43+
![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)
44+
45+
## `chart.appVersion`
46+
47+
13.0.0
48+
49+
## `chart.appVersionBadge`
50+
51+
![AppVersion: 13.0.0](https://img.shields.io/badge/AppVersion-13.0.0-informational?style=flat-square)
52+
53+
## `chart.badgesSection`
54+
55+
![Version: 1.0.0](https://img.shields.io/badge/Version-1.0.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 13.0.0](https://img.shields.io/badge/AppVersion-13.0.0-informational?style=flat-square)
56+
57+
## `chart.homepage`
58+
59+
https://github.com/norwoodj/helm-docs/tree/master/example-charts/full-template
60+
61+
## `chart.homepageLine`
62+
63+
**Homepage:** <https://github.com/norwoodj/helm-docs/tree/master/example-charts/full-template>
64+
65+
## `chart.maintainersHeader`
66+
67+
## Maintainers
68+
69+
## `chart.maintainersTable`
70+
71+
| Name | Email | Url |
72+
| ---- | ------ | --- |
73+
| John Norwood | <[email protected]> | |
74+
75+
## `chart.maintainersSection`
76+
77+
## Maintainers
78+
79+
| Name | Email | Url |
80+
| ---- | ------ | --- |
81+
| John Norwood | <[email protected]> | |
82+
83+
## `chart.sourcesHeader`
84+
85+
## Source Code
86+
87+
## `chart.sourcesList`
88+
89+
* <https://github.com/norwoodj/helm-docs/tree/master/example-charts/full-template>
90+
91+
## `chart.sourcesSection`
92+
93+
## Source Code
94+
95+
* <https://github.com/norwoodj/helm-docs/tree/master/example-charts/full-template>
96+
97+
## `chart.kubeVersion`
98+
99+
<=1.18
100+
101+
## `chart.kubeVersionLine`
102+
103+
Kubernetes: `<=1.18`
104+
105+
## `chart.requirementsHeader`
106+
107+
## Requirements
108+
109+
## `chart.requirementsTable`
110+
111+
| Repository | Name | Version |
112+
|------------|------|---------|
113+
| @stable | nginx-ingress | 0.22.1 |
114+
115+
## `chart.requirementsSection`
116+
117+
## Requirements
118+
119+
Kubernetes: `<=1.18`
120+
121+
| Repository | Name | Version |
122+
|------------|------|---------|
123+
| @stable | nginx-ingress | 0.22.1 |
124+
125+
## `chart.valuesHeader`
126+
127+
## Values
128+
129+
## `chart.valuesTable`
130+
131+
| Key | Type | Default | Description |
132+
|-----|------|---------|-------------|
133+
| controller.extraVolumes[0].configMap.name | string | `"nginx-ingress-config"` | Uses the name of the configmap created by this chart |
134+
| controller.extraVolumes[0].name | string | `"config-volume"` | |
135+
| controller.image.repository | string | `"nginx-ingress-controller"` | |
136+
| controller.image.tag | string | `"18.0831"` | |
137+
| controller.ingressClass | string | `"nginx"` | Name of the ingress class to route through this controller |
138+
| controller.name | string | `"controller"` | |
139+
| controller.persistentVolumeClaims | list | the chart will construct this list internally unless specified | List of persistent volume claims to create. For very long comments, break them into multiple lines. |
140+
| controller.podLabels | object | `{}` | The labels to be applied to instances of the controller pod |
141+
| controller.publishService.enabled | bool | `false` | Whether to expose the ingress controller to the public world |
142+
| controller.replicas | int | `nil` | Number of nginx-ingress pods to load balance between |
143+
| controller.service.annotations."external-dns.alpha.kubernetes.io/hostname" | string | `"stupidchess.jmn23.com"` | Hostname to be assigned to the ELB for the service |
144+
| controller.service.type | string | `"LoadBalancer"` | |
145+
146+
## `chart.valuesSection`
147+
148+
## Values
149+
150+
| Key | Type | Default | Description |
151+
|-----|------|---------|-------------|
152+
| controller.extraVolumes[0].configMap.name | string | `"nginx-ingress-config"` | Uses the name of the configmap created by this chart |
153+
| controller.extraVolumes[0].name | string | `"config-volume"` | |
154+
| controller.image.repository | string | `"nginx-ingress-controller"` | |
155+
| controller.image.tag | string | `"18.0831"` | |
156+
| controller.ingressClass | string | `"nginx"` | Name of the ingress class to route through this controller |
157+
| controller.name | string | `"controller"` | |
158+
| controller.persistentVolumeClaims | list | the chart will construct this list internally unless specified | List of persistent volume claims to create. For very long comments, break them into multiple lines. |
159+
| controller.podLabels | object | `{}` | The labels to be applied to instances of the controller pod |
160+
| controller.publishService.enabled | bool | `false` | Whether to expose the ingress controller to the public world |
161+
| controller.replicas | int | `nil` | Number of nginx-ingress pods to load balance between |
162+
| controller.service.annotations."external-dns.alpha.kubernetes.io/hostname" | string | `"stupidchess.jmn23.com"` | Hostname to be assigned to the ELB for the service |
163+
| controller.service.type | string | `"LoadBalancer"` | |
164+
165+
----------------------------------------------
166+
Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
{{ template "chart.header" . }}
2+
3+
4+
## `extra.flower`
5+
{{ template "extra.flower" . }}
6+
7+
## `chart.deprecationWarning`
8+
{{ template "chart.deprecationWarning" . }}
9+
10+
## `chart.name`
11+
12+
{{ template "chart.name" . }}
13+
14+
## `chart.description`
15+
16+
{{ template "chart.description" . }}
17+
18+
## `chart.version`
19+
20+
{{ template "chart.version" . }}
21+
22+
## `chart.versionBadge`
23+
24+
{{ template "chart.versionBadge" . }}
25+
26+
## `chart.type`
27+
28+
{{ template "chart.type" . }}
29+
30+
31+
## `chart.typeBadge`
32+
33+
{{ template "chart.typeBadge" . }}
34+
35+
## `chart.appVersion`
36+
37+
{{ template "chart.appVersion" . }}
38+
39+
## `chart.appVersionBadge`
40+
41+
{{ template "chart.appVersionBadge" . }}
42+
43+
## `chart.badgesSection`
44+
45+
{{ template "chart.badgesSection" . }}
46+
47+
## `chart.homepage`
48+
49+
{{ template "chart.homepage" . }}
50+
51+
## `chart.homepageLine`
52+
53+
{{ template "chart.homepageLine" . }}
54+
55+
## `chart.maintainersHeader`
56+
57+
{{ template "chart.maintainersHeader" . }}
58+
59+
## `chart.maintainersTable`
60+
61+
{{ template "chart.maintainersTable" . }}
62+
63+
## `chart.maintainersSection`
64+
65+
{{ template "chart.maintainersSection" . }}
66+
67+
## `chart.sourcesHeader`
68+
69+
{{ template "chart.sourcesHeader" . }}
70+
71+
## `chart.sourcesList`
72+
73+
{{ template "chart.sourcesList" . }}
74+
75+
## `chart.sourcesSection`
76+
77+
{{ template "chart.sourcesSection" . }}
78+
79+
## `chart.kubeVersion`
80+
81+
{{ template "chart.kubeVersion" . }}
82+
83+
## `chart.kubeVersionLine`
84+
85+
{{ template "chart.kubeVersionLine" . }}
86+
87+
## `chart.requirementsHeader`
88+
89+
{{ template "chart.requirementsHeader" . }}
90+
91+
## `chart.requirementsTable`
92+
93+
{{ template "chart.requirementsTable" . }}
94+
95+
## `chart.requirementsSection`
96+
97+
{{ template "chart.requirementsSection" . }}
98+
99+
## `chart.valuesHeader`
100+
101+
{{ template "chart.valuesHeader" . }}
102+
103+
## `chart.valuesTable`
104+
105+
{{ template "chart.valuesTable" . }}
106+
107+
## `chart.valuesSection`
108+
109+
{{ template "chart.valuesSection" . }}
110+
111+
{{ template "helm-docs.versionFooter" . }}

0 commit comments

Comments
 (0)