1
// Copyright 2015 Canonical Ltd.
2
// Licensed under the LGPLv3, see LICENSE file for details.
11
"github.com/juju/testing"
12
gc "gopkg.in/check.v1"
17
type ParseAliasFileSuite struct {
21
var _ = gc.Suite(&ParseAliasFileSuite{})
23
func (*ParseAliasFileSuite) TestMissing(c *gc.C) {
25
filename := filepath.Join(dir, "missing")
26
aliases := cmd.ParseAliasFile(filename)
27
c.Assert(aliases, gc.NotNil)
28
c.Assert(aliases, gc.HasLen, 0)
31
func (*ParseAliasFileSuite) TestParse(c *gc.C) {
33
filename := filepath.Join(dir, "missing")
35
# comments skipped, as are the blank lines, such as the line
36
# at the start of this file
39
flags = flags --with flag
41
# if the same alias name is used more than once, last one wins
44
# badly formated values are logged, but skipped
50
err := ioutil.WriteFile(filename, []byte(content), 0644)
51
c.Assert(err, gc.IsNil)
52
aliases := cmd.ParseAliasFile(filename)
53
c.Assert(aliases, gc.DeepEquals, map[string][]string{
54
"foo": []string{"trailing-space"},
55
"repeat": []string{"second"},
56
"flags": []string{"flags", "--with", "flag"},