File: common_test.go

package info (click to toggle)
golang-github-juju-utils 0.0~git20171220.f38c0b0-6
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,748 kB
  • sloc: makefile: 20
file content (52 lines) | stat: -rw-r--r-- 1,183 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2015 Canonical Ltd.
// Licensed under the LGPLv3, see LICENCE file for details.

package filepath_test

import (
	"github.com/juju/testing"
	gc "gopkg.in/check.v1"

	"github.com/juju/utils/filepath"
)

var _ = gc.Suite(&commonSuite{})

type commonSuite struct {
	testing.IsolationSuite
}

func (s commonSuite) TestSplitSuffixHasSuffix(c *gc.C) {
	path, suffix := filepath.SplitSuffix("spam.ext")

	c.Check(path, gc.Equals, "spam")
	c.Check(suffix, gc.Equals, ".ext")
}

func (s commonSuite) TestSplitSuffixNoSuffix(c *gc.C) {
	path, suffix := filepath.SplitSuffix("spam")

	c.Check(path, gc.Equals, "spam")
	c.Check(suffix, gc.Equals, "")
}

func (s commonSuite) TestSplitSuffixEmpty(c *gc.C) {
	path, suffix := filepath.SplitSuffix("")

	c.Check(path, gc.Equals, "")
	c.Check(suffix, gc.Equals, "")
}

func (s commonSuite) TestSplitSuffixDotFilePlain(c *gc.C) {
	path, suffix := filepath.SplitSuffix(".spam")

	c.Check(path, gc.Equals, ".spam")
	c.Check(suffix, gc.Equals, "")
}

func (s commonSuite) TestSplitSuffixDofileWithSuffix(c *gc.C) {
	path, suffix := filepath.SplitSuffix(".spam.ext")

	c.Check(path, gc.Equals, ".spam")
	c.Check(suffix, gc.Equals, ".ext")
}