~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/juju/testing/filetesting/isnotexist_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 2014 Canonical Ltd.
 
2
// Licensed under the LGPLv3, see LICENCE file for details.
 
3
 
 
4
package filetesting
 
5
 
 
6
import (
 
7
        "io/ioutil"
 
8
        "os"
 
9
        "path/filepath"
 
10
 
 
11
        jc "github.com/juju/testing/checkers"
 
12
        gc "gopkg.in/check.v1"
 
13
)
 
14
 
 
15
type isNotExistSuite struct{}
 
16
 
 
17
var _ = gc.Suite(&isNotExistSuite{})
 
18
 
 
19
func (*isNotExistSuite) TestIsNotExist(c *gc.C) {
 
20
        dir := c.MkDir()
 
21
        path := func(s string) string { return filepath.Join(dir, s) }
 
22
        err := ioutil.WriteFile(path("file"), []byte("blah"), 0644)
 
23
        c.Assert(err, gc.IsNil)
 
24
 
 
25
        _, err = os.Lstat(path("noexist"))
 
26
        c.Assert(err, jc.Satisfies, isNotExist)
 
27
 
 
28
        _, err = os.Lstat(path("file/parent-not-a-dir"))
 
29
        c.Assert(err, jc.Satisfies, isNotExist)
 
30
}