t.Errorf("validateChartVersion(%s) to return \"%s\", got no error",test.Version,test.ErrorMsg)
}
require.ErrorContainsf(t,validateChartVersion(badChart),test.ErrorMsg,"validateChartVersion(%s) to return \"%s\", got no error",test.Version,test.ErrorMsg)
}
for_,version:=rangesuccessTest{
badChart.Version=version
err:=validateChartVersion(badChart)
iferr!=nil{
t.Errorf("validateChartVersion(%s) to return no error, got a linter error",version)
}
assert.NoError(t,validateChartVersion(badChart),"validateChartVersion(%s) to return no error, got a linter error",version)
t.Errorf("validateChartVersionStrictSemVerV2(%s) to return \"%s\", got no error",test.Version,test.ErrorMsg)
}
require.ErrorContainsf(t,validateChartVersionStrictSemVerV2(badChart),test.ErrorMsg,"validateChartVersionStrictSemVerV2(%s) to return \"%s\", got no error",test.Version,test.ErrorMsg)
}
for_,version:=rangesuccessTest{
badChart.Version=version
err:=validateChartVersionStrictSemVerV2(badChart)
iferr!=nil{
t.Errorf("validateChartVersionStrictSemVerV2(%s) to return no error, got a linter error",version)
}
assert.NoError(t,validateChartVersionStrictSemVerV2(badChart),"validateChartVersionStrictSemVerV2(%s) to return no error, got a linter error",version)
t.Errorf("validateChartMaintainer(%s, %s) to return \"%s\", got no error",test.Name,test.Email,test.ErrorMsg)
}
require.ErrorContainsf(t,validateChartMaintainer(badChart),test.ErrorMsg,"validateChartMaintainer(%s, %s) to return \"%s\", got no error",test.Name,test.Email,test.ErrorMsg)
iferr==nil||!strings.Contains(err.Error(),"Valid extensions are .yaml, .yml, .tpl, or .txt"){
t.Errorf("validateAllowedExtension('%s') to return \"Valid extensions are .yaml, .yml, .tpl, or .txt\", got no error",test)
}
require.ErrorContainsf(t,validateAllowedExtension(test),"Valid extensions are .yaml, .yml, .tpl, or .txt","validateAllowedExtension('%s') to return \"Valid extensions are .yaml, .yml, .tpl, or .txt\", got no error",test)
t.Errorf("RunLinterRule(%d, \"chart\", %v), linter.Messages should now have %d message, we got %d",test.Severity,test.LintError,test.ExpectedMessages,len(linter.Messages))
t.Errorf("RunLinterRule(%d, \"chart\", %v), linter.HighestSeverity should be %d, we got %d",test.Severity,test.LintError,test.ExpectedHighestSeverity,linter.HighestSeverity)
}
ifisValid!=test.ExpectedReturn{
t.Errorf("RunLinterRule(%d, \"chart\", %v), should have returned %t but returned %t",test.Severity,test.LintError,test.ExpectedReturn,isValid)
}
assert.Lenf(t,linter.Messages,test.ExpectedMessages,"RunLinterRule(%d, \"chart\", %v), linter.Messages should now have %d message, we got %d",test.Severity,test.LintError,test.ExpectedMessages,len(linter.Messages))
assert.Equalf(t,linter.HighestSeverity,test.ExpectedHighestSeverity,"RunLinterRule(%d, \"chart\", %v), linter.HighestSeverity should be %d, we got %d",test.Severity,test.LintError,test.ExpectedHighestSeverity,linter.HighestSeverity)
assert.Equalf(t,isValid,test.ExpectedReturn,"RunLinterRule(%d, \"chart\", %v), should have returned %t but returned %t",test.Severity,test.LintError,test.ExpectedReturn,isValid)
// This is written directly to stdout, so we have to capture as is
if!strings.Contains(out,`Getting updates for unmanaged Helm repositories...`){
t.Errorf("No ‘unmanaged’ Helm repo used in test chartdependency or it doesn’t cause the creation "+
"of an ‘ad hoc’ repo index cache file\n%s",out)
}
assert.Contains(t,out,`Getting updates for unmanaged Helm repositories...`,"No ‘unmanaged’ Helm repo used in test chartdependency or it doesn’t cause the creation "+
t.Errorf("Expected NewOCIGetter to have insecureSkipVerifyTLS as %t, got %t",insecureSkipVerifyTLS,og.opts.insecureSkipVerifyTLS)
}
assert.Equal(t,insecureSkipVerifyTLS,og.opts.insecureSkipVerifyTLS,"Expected NewOCIGetter to have insecureSkipVerifyTLS as %t, got %t",insecureSkipVerifyTLS,og.opts.insecureSkipVerifyTLS)
// Test if setting registryClient is being passed to the ops
registryClient,err:=registry.NewClient()
iferr!=nil{
t.Fatal(err)
}
require.NoError(t,err)
g,err=NewOCIGetter(
WithRegistryClient(registryClient),
)
iferr!=nil{
t.Fatal(err)
}
require.NoError(t,err)
og,ok=g.(*OCIGetter)
if!ok{
t.Fatal("expected NewOCIGetter to produce an *OCIGetter")
}
require.True(t,ok,"expected NewOCIGetter to produce an *OCIGetter")
ifog.opts.registryClient!=registryClient{
t.Errorf("Expected NewOCIGetter to contain %p as RegistryClient, got %p",registryClient,og.opts.registryClient)
}
assert.Equal(t,registryClient,og.opts.registryClient,"Expected NewOCIGetter to contain %p as RegistryClient, got %p",registryClient,og.opts.registryClient)
t.Errorf("Expected NewOCIPusher to have insecureSkipVerifyTLS as %t, got %t",insecureSkipTLSVerify,op.opts.insecureSkipTLSVerify)
}
require.True(t,ok,"Expected NewOCIPusher to produce an *OCIPusher")
assert.Equal(t,pub,op.opts.certFile,"Expected NewOCIPusher to contain %q as the public key file, got %q",pub,op.opts.certFile)
assert.Equal(t,priv,op.opts.keyFile,"Expected NewOCIPusher to contain %q as the private key file, got %q",priv,op.opts.keyFile)
assert.Equal(t,ca,op.opts.caFile,"Expected NewOCIPusher to contain %q as the CA file, got %q",ca,op.opts.caFile)
assert.Equal(t,plainHTTP,op.opts.plainHTTP,"Expected NewOCIPusher to have plainHTTP as %t, got %t",plainHTTP,op.opts.plainHTTP)
assert.Equal(t,insecureSkipTLSVerify,op.opts.insecureSkipTLSVerify,"Expected NewOCIPusher to have insecureSkipVerifyTLS as %t, got %t",insecureSkipTLSVerify,op.opts.insecureSkipTLSVerify)
// Test if setting registryClient is being passed to the ops
registryClient,err:=registry.NewClient()
iferr!=nil{
t.Fatal(err)
}
require.NoError(t,err)
p,err=NewOCIPusher(
WithRegistryClient(registryClient),
)
iferr!=nil{
t.Fatal(err)
}
op,ok=p.(*OCIPusher)
if!ok{
t.Fatal("expected NewOCIPusher to produce an *OCIPusher")
}
require.NoError(t,err)
ifop.opts.registryClient!=registryClient{
t.Errorf("Expected NewOCIPusher to contain %p as RegistryClient, got %p",registryClient,op.opts.registryClient)
}
op,ok=p.(*OCIPusher)
require.True(t,ok,"expected NewOCIPusher to produce an *OCIPusher")
assert.Equal(t,registryClient,op.opts.registryClient,"Expected NewOCIPusher to contain %p as RegistryClient, got %p",registryClient,op.opts.registryClient)