1
// Copyright 2014 Canonical Ltd.
2
// Licensed under the LGPLv3, see LICENCE file for details.
10
"github.com/juju/testing"
11
jc "github.com/juju/testing/checkers"
12
gc "gopkg.in/check.v1"
14
"github.com/juju/utils"
17
type IsUbuntuSuite struct {
18
testing.IsolationSuite
21
var _ = gc.Suite(&IsUbuntuSuite{})
23
func (s *IsUbuntuSuite) patchLsbRelease(c *gc.C, name string) {
26
if runtime.GOOS != "windows" {
27
content = fmt.Sprintf("#!/bin/bash --norc\n%s", name)
28
execName = "lsb_release"
30
execName = "lsb_release.bat"
31
content = fmt.Sprintf("@echo off\r\n%s", name)
33
patchExecutable(s, c.MkDir(), execName, content)
36
func (s *IsUbuntuSuite) TestIsUbuntu(c *gc.C) {
37
s.patchLsbRelease(c, "echo Ubuntu")
38
c.Assert(utils.IsUbuntu(), jc.IsTrue)
41
func (s *IsUbuntuSuite) TestIsNotUbuntu(c *gc.C) {
42
s.patchLsbRelease(c, "echo Windows NT")
43
c.Assert(utils.IsUbuntu(), jc.IsFalse)
46
func (s *IsUbuntuSuite) TestIsNotUbuntuLsbReleaseNotFound(c *gc.C) {
47
if runtime.GOOS != "windows" {
48
s.patchLsbRelease(c, "exit 127")
50
c.Assert(utils.IsUbuntu(), jc.IsFalse)