Skip to content

Commit

Permalink
snap, s/snaptest: fix bug following symlink to component and update u…
Browse files Browse the repository at this point in the history
…nit test to match real behavior
  • Loading branch information
andrewphelpsj committed May 15, 2024
1 parent 5573bfd commit 6cd4807
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion snap/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -1564,7 +1564,7 @@ func ReadCurrentComponentInfo(component string, info *Info, container func(strin
return nil, fmt.Errorf("cannot read revision %s: %s", rev, err)
}

cont, err := container(linkSource)
cont, err := container(link)
if err != nil {
return nil, err
}
Expand Down
5 changes: 4 additions & 1 deletion snap/snaptest/snaptest.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ func MockComponentCurrent(c *check.C, yamlText string, info *snap.Info, csi snap
err := os.MkdirAll(filepath.Dir(link), 0755)
c.Assert(err, check.IsNil)

err = os.Symlink(mountDir, link)
linkDest, err := filepath.Rel(filepath.Dir(link), mountDir)
c.Assert(err, check.IsNil)

err = osutil.AtomicSymlink(linkDest, link)
c.Assert(err, check.IsNil)

return ci
Expand Down

0 comments on commit 6cd4807

Please sign in to comment.