~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/juju/gomaasapi/filesystem_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 2016 Canonical Ltd.
 
2
// Licensed under the LGPLv3, see LICENCE file for details.
 
3
 
 
4
package gomaasapi
 
5
 
 
6
import (
 
7
        jc "github.com/juju/testing/checkers"
 
8
        gc "gopkg.in/check.v1"
 
9
)
 
10
 
 
11
type filesystemSuite struct{}
 
12
 
 
13
var _ = gc.Suite(&filesystemSuite{})
 
14
 
 
15
func (*filesystemSuite) TestParse2_0(c *gc.C) {
 
16
        source := map[string]interface{}{
 
17
                "fstype":      "ext4",
 
18
                "mount_point": "/",
 
19
                "label":       "root",
 
20
                "uuid":        "fake-uuid",
 
21
        }
 
22
        fs, err := filesystem2_0(source)
 
23
        c.Assert(err, jc.ErrorIsNil)
 
24
        c.Check(fs.Type(), gc.Equals, "ext4")
 
25
        c.Check(fs.MountPoint(), gc.Equals, "/")
 
26
        c.Check(fs.Label(), gc.Equals, "root")
 
27
        c.Check(fs.UUID(), gc.Equals, "fake-uuid")
 
28
}
 
29
 
 
30
func (*filesystemSuite) TestParse2_Defaults(c *gc.C) {
 
31
        source := map[string]interface{}{
 
32
                "fstype":      "ext4",
 
33
                "mount_point": nil,
 
34
                "label":       nil,
 
35
                "uuid":        "fake-uuid",
 
36
        }
 
37
        fs, err := filesystem2_0(source)
 
38
        c.Assert(err, jc.ErrorIsNil)
 
39
        c.Check(fs.Type(), gc.Equals, "ext4")
 
40
        c.Check(fs.MountPoint(), gc.Equals, "")
 
41
        c.Check(fs.Label(), gc.Equals, "")
 
42
        c.Check(fs.UUID(), gc.Equals, "fake-uuid")
 
43
}
 
44
 
 
45
func (*filesystemSuite) TestParse2_0BadSchema(c *gc.C) {
 
46
        source := map[string]interface{}{
 
47
                "mount_point": "/",
 
48
                "label":       "root",
 
49
                "uuid":        "fake-uuid",
 
50
        }
 
51
        _, err := filesystem2_0(source)
 
52
        c.Assert(err, jc.Satisfies, IsDeserializationError)
 
53
}