@ -24,6 +24,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
v2release "helm.sh/helm/v4/internal/release/v2"
v2release "helm.sh/helm/v4/internal/release/v2"
chart "helm.sh/helm/v4/pkg/chart/v2"
"helm.sh/helm/v4/pkg/release/common"
"helm.sh/helm/v4/pkg/release/common"
rspb "helm.sh/helm/v4/pkg/release/v1"
rspb "helm.sh/helm/v4/pkg/release/v1"
)
)
@ -35,9 +36,10 @@ func TestNewDefaultAccessor(t *testing.T) {
req := require . New ( t )
req := require . New ( t )
// Create release
// Create release
info := & rspb . Info { Status : common . StatusDeployed , LastDeployed : time . Now ( ) . Add ( 1000 ) }
info := & rspb . Info { Status : common . StatusDeployed , LastDeployed : time . Now ( ) . Add ( 1000 ) , Notes : "test notes" }
labels := make ( map [ string ] string )
labels := make ( map [ string ] string )
labels [ "foo" ] = "bar"
labels [ "foo" ] = "bar"
ch := & chart . Chart { Metadata : & chart . Metadata { Name : "happy-cats" , Version : "1.0.0" } }
rel := & rspb . Release {
rel := & rspb . Release {
Name : "happy-cats" ,
Name : "happy-cats" ,
Version : 2 ,
Version : 2 ,
@ -45,6 +47,16 @@ func TestNewDefaultAccessor(t *testing.T) {
Labels : labels ,
Labels : labels ,
Namespace : "default" ,
Namespace : "default" ,
ApplyMethod : "csa" ,
ApplyMethod : "csa" ,
Chart : ch ,
Manifest : "test manifest content" ,
Hooks : [ ] * rspb . Hook {
{
Name : "test-hook" ,
Kind : "Job" ,
Path : "templates/hook.yaml" ,
Manifest : "hook manifest" ,
} ,
} ,
}
}
// newDefaultAccessor should not be called directly Instead, NewAccessor should be
// newDefaultAccessor should not be called directly Instead, NewAccessor should be
@ -65,6 +77,21 @@ func TestNewDefaultAccessor(t *testing.T) {
is . Equal ( rel . Version , accessor . Version ( ) )
is . Equal ( rel . Version , accessor . Version ( ) )
is . Equal ( rel . ApplyMethod , accessor . ApplyMethod ( ) )
is . Equal ( rel . ApplyMethod , accessor . ApplyMethod ( ) )
is . Equal ( rel . Labels , accessor . Labels ( ) )
is . Equal ( rel . Labels , accessor . Labels ( ) )
is . Equal ( rel . Manifest , accessor . Manifest ( ) )
is . Equal ( rel . Info . Notes , accessor . Notes ( ) )
is . Equal ( rel . Info . Status . String ( ) , accessor . Status ( ) )
is . Equal ( rel . Info . LastDeployed , accessor . DeployedAt ( ) )
is . Equal ( rel . Chart , accessor . Chart ( ) )
// Verify hooks are accessible
hooks := accessor . Hooks ( )
is . Len ( hooks , 1 )
// Test hook accessor
hookAccessor , err := newDefaultHookAccessor ( hooks [ 0 ] )
req . NoError ( err )
is . Equal ( "templates/hook.yaml" , hookAccessor . Path ( ) )
is . Equal ( "hook manifest" , hookAccessor . Manifest ( ) )
}
}
func TestNewDefaultAccessorV2 ( t * testing . T ) {
func TestNewDefaultAccessorV2 ( t * testing . T ) {