blueprint: DeepCopy() cannot fail
Don't return an error value, as it is always nil. Signed-off-by: Tom Gundersen <teg@jklm.no>
This commit is contained in:
parent
3f2e7be9cf
commit
dc794a6d31
3 changed files with 4 additions and 14 deletions
|
|
@ -40,7 +40,7 @@ type Group struct {
|
|||
|
||||
// DeepCopy returns a deep copy of the blueprint
|
||||
// This uses json.Marshal and Unmarshal which are not very efficient
|
||||
func (b *Blueprint) DeepCopy() (Blueprint, error) {
|
||||
func (b *Blueprint) DeepCopy() Blueprint {
|
||||
bpJSON, err := json.Marshal(b)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
@ -51,7 +51,7 @@ func (b *Blueprint) DeepCopy() (Blueprint, error) {
|
|||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return bp, nil
|
||||
return bp
|
||||
}
|
||||
|
||||
// Initialize ensures that the blueprint has sane defaults for any missing fields
|
||||
|
|
|
|||
|
|
@ -18,8 +18,7 @@ func TestDeepCopy(t *testing.T) {
|
|||
{Name: "dep-package2", Version: "*"}},
|
||||
}
|
||||
|
||||
bpCopy, err := bpOrig.DeepCopy()
|
||||
require.NoError(t, err)
|
||||
bpCopy := bpOrig.DeepCopy()
|
||||
require.Equalf(t, bpOrig, bpCopy, "Blueprints.DeepCopy is different from original.")
|
||||
|
||||
// Modify the copy
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue