github.com/billybanfield/evergreen@v0.0.0-20170525200750-eeee692790f7/plugin/builtin/attach/attach_plugin_test.go (about) 1 package attach 2 3 import ( 4 "testing" 5 6 "github.com/evergreen-ci/evergreen/model/artifact" 7 "github.com/evergreen-ci/evergreen/model/user" 8 . "github.com/smartystreets/goconvey/convey" 9 ) 10 11 func TestFileVisibility(t *testing.T) { 12 13 Convey("With a list of files with 4 ui visibility permissions", t, func() { 14 files := []artifact.File{ 15 {Name: "Private", Visibility: artifact.Private}, 16 {Name: "Public", Visibility: artifact.Public}, 17 {Name: "Hidden", Visibility: artifact.None}, 18 {Name: "Unset", Visibility: ""}, 19 } 20 21 Convey("and no user", func() { 22 stripped := stripHiddenFiles(files, nil) 23 24 Convey("the original array should be unmodified", func() { 25 So(len(files), ShouldEqual, 4) 26 }) 27 28 Convey("and all only the public and unset files should be returned", func() { 29 So(stripped[0].Name, ShouldEqual, "Public") 30 So(stripped[1].Name, ShouldEqual, "Unset") 31 So(len(stripped), ShouldEqual, 2) 32 }) 33 }) 34 35 Convey("with a user", func() { 36 stripped := stripHiddenFiles(files, &user.DBUser{}) 37 38 Convey("the original array should be unmodified", func() { 39 So(len(files), ShouldEqual, 4) 40 }) 41 42 Convey("and all but the 'None' files should be returned", func() { 43 So(stripped[0].Name, ShouldEqual, "Private") 44 So(stripped[1].Name, ShouldEqual, "Public") 45 So(stripped[2].Name, ShouldEqual, "Unset") 46 So(len(stripped), ShouldEqual, 3) 47 }) 48 }) 49 }) 50 51 }