github.com/sandwich-go/boost@v1.3.29/xos/hide_test.go (about)

     1  package xos
     2  
     3  import (
     4  	. "github.com/smartystreets/goconvey/convey"
     5  	"os"
     6  	"path/filepath"
     7  	"testing"
     8  )
     9  
    10  func TestHide(t *testing.T) {
    11  	Convey("hide", t, func() {
    12  		var tmpFile = filepath.Join(os.TempDir(), "test_dir")
    13  		_, err := IsHidden(tmpFile)
    14  		So(err, ShouldNotBeNil)
    15  		So(MkdirAll(tmpFile), ShouldBeNil)
    16  		MustFilePutContents(tmpFile, []byte("a"))
    17  		is, err1 := IsHidden(tmpFile)
    18  		So(err1, ShouldBeNil)
    19  		So(is, ShouldBeFalse)
    20  		var newTmpFile string
    21  		newTmpFile, err = Hide(tmpFile)
    22  		So(err, ShouldBeNil)
    23  		is, err = IsHidden(newTmpFile)
    24  		So(err, ShouldBeNil)
    25  		So(is, ShouldBeTrue)
    26  		tmpFile, err = UnHide(newTmpFile)
    27  		So(err, ShouldBeNil)
    28  		is, err = IsHidden(tmpFile)
    29  		So(err, ShouldBeNil)
    30  		So(is, ShouldBeFalse)
    31  
    32  		So(os.RemoveAll(tmpFile), ShouldBeNil)
    33  	})
    34  }