github.com/meulengracht/snapd@v0.0.0-20210719210640-8bde69bcc84e/cmd/snap/cmd_paths_test.go (about) 1 // -*- Mode: Go; indent-tabs-mode: t -*- 2 3 /* 4 * Copyright (C) 2018 Canonical Ltd 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License version 3 as 8 * published by the Free Software Foundation. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 * 18 */ 19 20 package main_test 21 22 import ( 23 . "gopkg.in/check.v1" 24 25 snap "github.com/snapcore/snapd/cmd/snap" 26 "github.com/snapcore/snapd/dirs" 27 "github.com/snapcore/snapd/release" 28 ) 29 30 func (s *SnapSuite) TestPathsUbuntu(c *C) { 31 restore := release.MockReleaseInfo(&release.OS{ID: "ubuntu"}) 32 defer restore() 33 defer dirs.SetRootDir("/") 34 35 dirs.SetRootDir("/") 36 _, err := snap.Parser(snap.Client()).ParseArgs([]string{"debug", "paths"}) 37 c.Assert(err, IsNil) 38 c.Assert(s.Stdout(), Equals, ""+ 39 "SNAPD_MOUNT=/snap\n"+ 40 "SNAPD_BIN=/snap/bin\n"+ 41 "SNAPD_LIBEXEC=/usr/lib/snapd\n") 42 c.Assert(s.Stderr(), Equals, "") 43 } 44 45 func (s *SnapSuite) TestPathsFedora(c *C) { 46 restore := release.MockReleaseInfo(&release.OS{ID: "fedora"}) 47 defer restore() 48 defer dirs.SetRootDir("/") 49 50 dirs.SetRootDir("/") 51 _, err := snap.Parser(snap.Client()).ParseArgs([]string{"debug", "paths"}) 52 c.Assert(err, IsNil) 53 c.Assert(s.Stdout(), Equals, ""+ 54 "SNAPD_MOUNT=/var/lib/snapd/snap\n"+ 55 "SNAPD_BIN=/var/lib/snapd/snap/bin\n"+ 56 "SNAPD_LIBEXEC=/usr/libexec/snapd\n") 57 c.Assert(s.Stderr(), Equals, "") 58 } 59 60 func (s *SnapSuite) TestPathsArch(c *C) { 61 defer dirs.SetRootDir("/") 62 63 // old /etc/os-release contents 64 restore := release.MockReleaseInfo(&release.OS{ID: "arch", IDLike: []string{"archlinux"}}) 65 defer restore() 66 67 dirs.SetRootDir("/") 68 _, err := snap.Parser(snap.Client()).ParseArgs([]string{"debug", "paths"}) 69 c.Assert(err, IsNil) 70 c.Assert(s.Stdout(), Equals, ""+ 71 "SNAPD_MOUNT=/var/lib/snapd/snap\n"+ 72 "SNAPD_BIN=/var/lib/snapd/snap/bin\n"+ 73 "SNAPD_LIBEXEC=/usr/lib/snapd\n") 74 c.Assert(s.Stderr(), Equals, "") 75 76 s.ResetStdStreams() 77 78 // new contents, as set by filesystem-2018.12-1 79 restore = release.MockReleaseInfo(&release.OS{ID: "archlinux"}) 80 defer restore() 81 82 dirs.SetRootDir("/") 83 _, err = snap.Parser(snap.Client()).ParseArgs([]string{"debug", "paths"}) 84 c.Assert(err, IsNil) 85 c.Assert(s.Stdout(), Equals, ""+ 86 "SNAPD_MOUNT=/var/lib/snapd/snap\n"+ 87 "SNAPD_BIN=/var/lib/snapd/snap/bin\n"+ 88 "SNAPD_LIBEXEC=/usr/lib/snapd\n") 89 c.Assert(s.Stderr(), Equals, "") 90 }