-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add additional directories option (#5)
- Loading branch information
1 parent
b0fe82b
commit 17b5d4d
Showing
7 changed files
with
106 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package framework | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
"testing" | ||
) | ||
|
||
func TestLoader(t *testing.T) { | ||
const testdataPath = "testdata/suite" | ||
|
||
tests := map[string]struct { | ||
opts []LoaderOpt | ||
expectedFunc func(*testing.T, *Test) | ||
additionalDir string | ||
}{ | ||
"With root dir": { | ||
expectedFunc: func(t *testing.T, helmTest *Test) { | ||
assert.Len(t, helmTest.Tests, 2) | ||
}, | ||
}, | ||
"Loader loads test hierarchy": { | ||
expectedFunc: func(t *testing.T, test *Test) { | ||
require.Len(t, test.Tests[1].Tests, 1) | ||
childTest := test.findFirst([]string{testdataPath, "helm.test.yaml", "test in helm.test.yaml", "with overwrites"}) | ||
assert.Equal(t, "with overwrites", childTest.Name) | ||
assert.Equal(t, map[string]interface {}{"testValue":"value overwrite"}, childTest.Values) | ||
}, | ||
}, | ||
"Loader loads additional dir": { | ||
additionalDir: "testdata/additional_dir", | ||
expectedFunc: func(t *testing.T, test *Test) { | ||
childTest := test.findFirst([]string{testdataPath, "additional.test.yaml"}) | ||
require.NotNil(t, test) | ||
assert.Equal(t, "additional.test.yaml", childTest.Name) | ||
}, | ||
}, | ||
} | ||
|
||
for name, tt := range tests { | ||
tt := tt | ||
t.Run(name, func(t *testing.T) { | ||
var opts []LoaderOpt | ||
if tt.additionalDir != "" { | ||
opts = append(opts, WithAdditionalTestDirs(tt.additionalDir)) | ||
} | ||
|
||
loader := NewLoader(testdataPath, opts...) | ||
helmTests, err := loader.LoadSuite() | ||
require.NoError(t, err) | ||
|
||
tt.expectedFunc(t, helmTests) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
tests: | ||
- name: test in additional.test.yaml | ||
values: | ||
additional: additionalValue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
tests: | ||
- name: test in helm.test.yaml | ||
values: | ||
testValue: value | ||
|
||
tests: | ||
- name: with overwrites | ||
values: | ||
testValue: value overwrite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
tests: | ||
- name: test in suite.yaml |