@ -237,27 +237,36 @@ func makeMeSomeReleases(store *storage.Storage, t *testing.T) {
}
}
func TestFilterList ( t * testing . T ) {
func TestFilterList ( t * testing . T ) {
one := releaseStub ( )
t. Run ( "should filter old versions of the same release" , func ( t * testing . T ) {
one . Name = "one"
r1 := releaseStub ( )
one . Namespace = "default "
r1 . Name = "r "
one . Version = 1
r1 . Version = 1
two := releaseStub ( )
r2 := releaseStub ( )
two . Name = "two "
r2 . Name = "r "
two . Namespace = "default"
r2 . Version = 2
two . Version = 1
another := releaseStub ( )
anotherOldOne := releaseStub ( )
another . Name = "another"
anotherOldOne . Name = "one"
another . Version = 1
anotherOldOne . Namespace = "testing"
anotherOldOne . Version = 1
filteredList := filterList ( [ ] * release . Release { r1 , r2 , another } )
anotherOne := releaseStub ( )
expectedFilteredList := [ ] * release . Release { r2 , another }
anotherOne . Name = "one"
anotherOne . Namespace = "testing"
assert . ElementsMatch ( t , expectedFilteredList , filteredList )
anotherOne . Version = 2
} )
list := [ ] * release . Release { one , two , anotherOne }
t . Run ( "should not filter out any version across namespaces" , func ( t * testing . T ) {
expectedFilteredList := [ ] * release . Release { one , two , anotherOne }
r1 := releaseStub ( )
r1 . Name = "r"
r1 . Namespace = "default"
r1 . Version = 1
r2 := releaseStub ( )
r2 . Name = "r"
r2 . Namespace = "testing"
r2 . Version = 2
filteredList := filterList ( list )
filteredList := filterList ( [ ] * release . Release { r1 , r2 } )
expectedFilteredList := [ ] * release . Release { r1 , r2 }
assert . ElementsMatch ( t , expectedFilteredList , filteredList )
assert . ElementsMatch ( t , expectedFilteredList , filteredList )
} )
}
}