~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/juju/utils/file_windows_test.go

  • Committer: Nicholas Skaggs
  • Date: 2016-10-24 20:56:05 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161024205605-z8lta0uvuhtxwzwl
Initi with beta15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2013 Canonical Ltd.
 
2
// Copyright 2014 Cloudbase Solutions SRL
 
3
// Licensed under the LGPLv3, see LICENCE file for details.
 
4
 
 
5
// +build windows
 
6
 
 
7
package utils_test
 
8
 
 
9
import (
 
10
        gc "gopkg.in/check.v1"
 
11
 
 
12
        "github.com/juju/utils"
 
13
)
 
14
 
 
15
type windowsFileSuite struct {
 
16
}
 
17
 
 
18
var _ = gc.Suite(&windowsFileSuite{})
 
19
 
 
20
func (s *windowsFileSuite) TestMakeFileURL(c *gc.C) {
 
21
        var makeFileURLTests = []struct {
 
22
                in       string
 
23
                expected string
 
24
        }{{
 
25
                in:       "file://C:\\foo\\baz",
 
26
                expected: "file://C:/foo/baz",
 
27
        }, {
 
28
                in:       "C:\\foo\\baz",
 
29
                expected: "file://C:/foo/baz",
 
30
        }, {
 
31
                in:       "http://foo/baz",
 
32
                expected: "http://foo/baz",
 
33
        }, {
 
34
                in:       "file://C:/foo/baz",
 
35
                expected: "file://C:/foo/baz",
 
36
        }}
 
37
 
 
38
        for i, t := range makeFileURLTests {
 
39
                c.Logf("Test %d", i)
 
40
                c.Assert(utils.MakeFileURL(t.in), gc.Equals, t.expected)
 
41
        }
 
42
}
 
43
 
 
44
func (s *windowsFileSuite) TestEnsureBaseDir(c *gc.C) {
 
45
        c.Assert(utils.EnsureBaseDir(`C:\r`, `C:\a\b`), gc.Equals, `C:\r\a\b`)
 
46
        c.Assert(utils.EnsureBaseDir(`C:\r`, `D:\a\b`), gc.Equals, `C:\r\a\b`)
 
47
        c.Assert(utils.EnsureBaseDir(`C:`, `D:\a\b`), gc.Equals, `C:\a\b`)
 
48
        c.Assert(utils.EnsureBaseDir(`C:`, `\a\b`), gc.Equals, `C:\a\b`)
 
49
        c.Assert(utils.EnsureBaseDir(``, `C:\a\b`), gc.Equals, `C:\a\b`)
 
50
}