mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 10:15:22 +00:00
Update full linter list and enable some easily resolved new ones
This commit is contained in:
@@ -32,6 +32,7 @@ func run(input string, f kio.Filter) (string, error) {
|
||||
|
||||
// RunFilter runs filter and panic if there is error
|
||||
func RunFilter(t *testing.T, input string, f kio.Filter) string {
|
||||
t.Helper()
|
||||
output, err := run(input, f)
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
@@ -41,6 +42,7 @@ func RunFilter(t *testing.T, input string, f kio.Filter) string {
|
||||
|
||||
// RunFilterE runs filter and return error if there is
|
||||
func RunFilterE(t *testing.T, input string, f kio.Filter) (string, error) {
|
||||
t.Helper()
|
||||
output, err := run(input, f)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
||||
@@ -22,11 +22,13 @@ type Harness struct {
|
||||
}
|
||||
|
||||
func MakeHarness(t *testing.T) Harness {
|
||||
t.Helper()
|
||||
return MakeHarnessWithFs(t, filesys.MakeFsInMemory())
|
||||
}
|
||||
|
||||
func MakeHarnessWithFs(
|
||||
t *testing.T, fSys filesys.FileSystem) Harness {
|
||||
t.Helper()
|
||||
return Harness{
|
||||
t: t,
|
||||
fSys: fSys,
|
||||
|
||||
@@ -47,6 +47,7 @@ type HarnessEnhanced struct {
|
||||
}
|
||||
|
||||
func MakeEnhancedHarness(t *testing.T) *HarnessEnhanced {
|
||||
t.Helper()
|
||||
r := makeBaseEnhancedHarness(t)
|
||||
r.Harness = MakeHarnessWithFs(t, filesys.MakeFsInMemory())
|
||||
// Point the Harness's file loader to the root ('/')
|
||||
@@ -56,6 +57,7 @@ func MakeEnhancedHarness(t *testing.T) *HarnessEnhanced {
|
||||
}
|
||||
|
||||
func MakeEnhancedHarnessWithTmpRoot(t *testing.T) *HarnessEnhanced {
|
||||
t.Helper()
|
||||
r := makeBaseEnhancedHarness(t)
|
||||
fSys := filesys.MakeFsOnDisk()
|
||||
r.Harness = MakeHarnessWithFs(t, fSys)
|
||||
@@ -72,6 +74,7 @@ func MakeEnhancedHarnessWithTmpRoot(t *testing.T) *HarnessEnhanced {
|
||||
}
|
||||
|
||||
func makeBaseEnhancedHarness(t *testing.T) *HarnessEnhanced {
|
||||
t.Helper()
|
||||
rf := resmap.NewFactory(
|
||||
provider.NewDefaultDepProvider().GetResourceFactory())
|
||||
return &HarnessEnhanced{
|
||||
|
||||
@@ -26,6 +26,7 @@ func AssertActualEqualsExpectedWithTweak(
|
||||
t *testing.T,
|
||||
m resmap.ResMap,
|
||||
tweaker func([]byte) []byte, expected string) {
|
||||
t.Helper()
|
||||
if m == nil {
|
||||
t.Fatalf("Map should not be nil.")
|
||||
}
|
||||
@@ -49,13 +50,14 @@ func AssertActualEqualsExpectedWithTweak(
|
||||
// Pretty printing of file differences.
|
||||
func reportDiffAndFail(
|
||||
t *testing.T, actual []byte, expected string) {
|
||||
t.Helper()
|
||||
sE, maxLen := convertToArray(expected)
|
||||
sA, _ := convertToArray(string(actual))
|
||||
fmt.Println("===== ACTUAL BEGIN ========================================")
|
||||
fmt.Print(string(actual))
|
||||
fmt.Println("===== ACTUAL END ==========================================")
|
||||
format := fmt.Sprintf("%%s %%-%ds %%s\n", maxLen+4)
|
||||
limit := 0
|
||||
var limit int
|
||||
if len(sE) < len(sA) {
|
||||
limit = len(sE)
|
||||
} else {
|
||||
|
||||
@@ -25,6 +25,7 @@ type pluginTestEnv struct {
|
||||
|
||||
// newPluginTestEnv returns a new instance of pluginTestEnv.
|
||||
func newPluginTestEnv(t *testing.T) *pluginTestEnv {
|
||||
t.Helper()
|
||||
return &pluginTestEnv{t: t}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,18 +20,22 @@ type rmBuilder struct {
|
||||
}
|
||||
|
||||
func NewSeededRmBuilder(t *testing.T, rf *resource.Factory, m resmap.ResMap) *rmBuilder {
|
||||
t.Helper()
|
||||
return &rmBuilder{t: t, rf: rf, m: m}
|
||||
}
|
||||
|
||||
func NewRmBuilder(t *testing.T, rf *resource.Factory) *rmBuilder {
|
||||
t.Helper()
|
||||
return NewSeededRmBuilder(t, rf, resmap.New())
|
||||
}
|
||||
|
||||
func NewRmBuilderDefault(t *testing.T) *rmBuilder {
|
||||
t.Helper()
|
||||
return NewSeededRmBuilderDefault(t, resmap.New())
|
||||
}
|
||||
|
||||
func NewSeededRmBuilderDefault(t *testing.T, m resmap.ResMap) *rmBuilder {
|
||||
t.Helper()
|
||||
return NewSeededRmBuilder(
|
||||
t, provider.NewDefaultDepProvider().GetResourceFactory(), m)
|
||||
}
|
||||
|
||||
@@ -22,11 +22,13 @@ const SAD = "i'm not happy Bob, NOT HAPPY"
|
||||
|
||||
// MakeHappyMapValidator makes a fakeValidator that always passes.
|
||||
func MakeHappyMapValidator(t *testing.T) *fakeValidator {
|
||||
t.Helper()
|
||||
return &fakeValidator{happy: true, t: t}
|
||||
}
|
||||
|
||||
// MakeSadMapValidator makes a fakeValidator that always fails.
|
||||
func MakeSadMapValidator(t *testing.T) *fakeValidator {
|
||||
t.Helper()
|
||||
return &fakeValidator{happy: false, t: t}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user